[BUG] Selecting lines ending in ' or "

Doug Way dway at riskmetrics.com
Thu Jan 18 06:05:14 UTC 2001


> >On Wed, 17 Jan 2001 18:56:13 -0500, Doug Way <dway at riskmetrics.com> wrote:
> >> - Correct the selection mechanism in text views so that clicking at the end of a
> >> line ending with ' or " selects the line (as it does in other cases) rather than
> >> the text following the line.
> 
> Jon Hylands <jon at huv.com> replied...
> >The problem is that when you select the character to the immediate left or
> >right of a single or double quote, the system overrides the line selection
> >mechanism in favor of the quote-matching mechanism.
> >
> >The same thing happens if you end a line with an open paren or open square
> >bracket (and probably some other special characters as well).
> >
> >All in all I'd rather have the behavior that is in the system now than lose
> >the ability to match quotes and brackets...
> 
Dan Ingalls replied:
> One needn't throw the baby out with the bath water.

Right, I wouldn't want to lose the ability to match quotes and brackets
either.  I figured there was probably a way to keep both, but have line
selection occur in this particular case.

> The bracket matching scheme is very simple (I wrote it way back):
> 
> It looks FIRST to the left for a matchable character and if it finds one it searches right for the match.
> THEN it looks to the right for a matchable character and if it finds one it searches left for the match.
> 
> It would not be hard to add a precedence rule:
>         If there is a quote on one side and another matchable character
>         on the other, then match the non-quote,
> or the more specific
>         If there is a quote on one side and a CR on the other,
>         then match the CR.
> 
> It's not clear to me that this deserves to be called a "correction".  I can equally imagine the new scheme doing the "wrong" thing for someone and, when it did, it would three rules instead of two to explain how it had failed.    ;-)
> 
>         - Dan

Perhaps "enhancement" would be a better term. :-)  After looking at it
harder I'll admit that it's not too cut and dried.

Still, I tend to agree with Ivan that, for this rather specific case,
one almost always wants to select the line instead of match the quote. 
This probably is most relevant to double quotes (comments), since
comments nearly always end with a closing quote at the end of a line,
but very rarely have the opening quote at the end of a line.  So,
clicking at the end of a commented line (for example a method comment)
generally does the wrong thing.

So, if it had to be enhanced, I would go with adding the 2nd precedence
rule above, the one specific to CRs.  Adding that first rule would be
interesting, but it might have more undesirable side-effects (e.g. you
would no longer be able to match quotes by clicking after the first
single quote in this statement:  rightParen := ')'.  Okay, probably not
a great loss.)

Or, I suppose I could just get used to clicking on the beginning of a
line to select entire lines, which currently always works (even for
comments), but there's a lot more room for mouse clicks at the end of
the line.  (Or, if we had open-quote and close-quote character glyphs,
this wouldn't be a problem. :-) )

- Doug Way
  dway at riskmetrics.com





More information about the Squeak-dev mailing list