[wingide-users] Indent analysis confused

Michael Foord fuzzyman at voidspace.org.uk
Wed Nov 4 12:21:36 MST 2009

Wingware Support wrote:
> Tom Stambaugh wrote:
>> PyDoc and the various other tools that use docstrings (such as the 
>> "Source Assistant" of WingIDE) are likely to at least be stressed if 
>> not broken, because I would expect the un-indented second line of 
>> hashes to potentially violate the syntactically-significant 
>> whitespace grammar of Python. I know that comments are supposed to be 
>> invisible, but as you can see from the indent manager they really 
>> aren't.
> The reason we chose to pay attention to comment position in the indent
> manager (for auto-indent only, I believe) was that _usually_ the 
> comment's
> position is significant and using it is preferable to requiring the user
> to dedent twice for example in:
> if x:
>   pass
> # comment (had to dedent here)
> <don't want to have to dedent again here!>
> This is a very common case in coding so I think what we're doing is
> in general correct.  The algorithm is actually more complex that just
> looking at comments all the time (e.g. it ignores block comments in
> certain cases).  As I noted earlier, I think we can enhance this to work
> OK in the case Michael reported w/o really breaking anything.  It's
> (probably) reasonable enough to stubbornly indent again for any first
> non-comment line in a code block.  Most comments here will already be
> indented to the "right" position.

Cool. It could be a good rule of thumb that if the indent analysis 
suggests an indent location that results in invalid syntax then it is 
probably wrong. :-)

A specific rule for this situation would be good though.

> This is good example of how being "smarter" in an IDE can backfire.  
> There
> is an unavoidable tension between doing more than just being a plain text
> editor and sometimes doing too much.
> BTW, it's useful to get feedback like this.  A lot of the value in Wing
> is from long years of tweaking in response to user reports.

It is amazing how much effort you have to put in just for your user to 
*not* notice what you are doing. :-)

Many thanks,



More information about the wingide-users mailing list