Bug 130007

Summary: add matching quotes to matching brackets
Product: [WebTools] WTP Source Editing Reporter: Amy Wu <for.work.things>
Component: wst.sseAssignee: Nick Sandonato <nsand.dev>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: enhancement    
Priority: P3 CC: d_a_carver, itewksbu, thatnitind
Version: 1.5Keywords: bugday, helpwanted
Target Milestone: Future   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Amy Wu CLA 2006-03-01 13:30:46 EST
Source editors currently have matching brackets feature, where matching <>(){} are all highlighted.  It would be nice if ""'' were also added.
Comment 1 David Carver CLA 2007-11-29 19:04:39 EST
Amy, I'll take a look at this.

Comment 2 David Carver CLA 2007-11-30 10:35:52 EST
Amy, exactly which editors are you looking for this functionality?  Are you looking for it as a default in the SSE editor in general, or are there particular editors where this would be helpful.

Comment 3 David Carver CLA 2007-11-30 12:35:57 EST
From what I can tell here, it should be a simple matter of adding DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE to the region to check, unless there is another of the attribute constants that should be added instead.

I tried the XML_TAG_ATTRIBUTE_VALUE and it didn't seem to make any difference in the XMLDocumentRegionEdgeMatcher.  Is there a better constant to use?

Comment 4 David Carver CLA 2007-11-30 13:24:53 EST
Alright...yes another comment.  I think there is going to be a potential problem with getting the ' and " added as RegionEndMatchers.   The problem is that the quote and apostrophe are currently included in the XML_TAG_ATTRIBUTE_VALUE scope.  You can see this as being true as when this tag is used by the LineStyle provider to italicize something in the source editor, the quotes/apostrophes are also italized not just the content between them.

So unless there is a way to change the scope and make the region for the XML_TAG_ATTRIBUTE_VALUE not include the apostrophe and quote then we can't scope the begining and end of the region correctly.
Comment 5 Amy Wu CLA 2007-11-30 14:09:42 EST
I was thinking for all source editors.
Comment 6 Amy Wu CLA 2007-11-30 14:18:35 EST
I'm not sure about the answers to your other questions, but offhand, I'd say part of the reason why we haven't fixed this bug sooner is probably because we ran into the same problems you're running into now.

Rather than trying to use the DocumentRegionEdgeMatcher, maybe it'd be easier to just use the default edge matcher and just straight up match quotes to quotes rather than trying to be way smart about it?  If you use the DocumentRegionEdgeMatcher, would it have matched quotes if they were used in tag content like <tag>i am using "airquotes"</tag>?
Comment 7 David Carver CLA 2007-11-30 14:41:05 EST
(In reply to comment #6)
> I'm not sure about the answers to your other questions, but offhand, I'd say
> part of the reason why we haven't fixed this bug sooner is probably because we
> ran into the same problems you're running into now.
> 
> Rather than trying to use the DocumentRegionEdgeMatcher, maybe it'd be easier
> to just use the default edge matcher and just straight up match quotes to
> quotes rather than trying to be way smart about it?  If you use the
> DocumentRegionEdgeMatcher, would it have matched quotes if they were used in
> tag content like <tag>i am using "airquotes"</tag>?
> 

If we use the Default matcher, it'll match where ever those appear, I believe.  Which isn't what we want.   We really only want it to match within the scope of an attribute declaration value.  Unfortunately it appears that to do this, the Lexical Tokenizer Parser would need to be redone as well, as possibly the structured text editor.   The key here is clearly specifying a token for the start and end regions of the attributes. 
Comment 8 Nitin Dahyabhai CLA 2007-12-03 05:20:31 EST
The current matcher just checks the document region's reported type and if it falls within the given list and the cursor is at one of that document region's "edges", reports a match.  It's not really even looking at the text, so it would never match quotes within XML content as shown in comment 6.

I don't think this feature is quite important enough to justify the memory increase from breaking attribute values into separate tokens.  Even as an in-place region container it would more than triple the size of an attribute value region.  As the attribute value region contains a textLength integer indicating the last non-whitespace character, it should be possible to check the character at that index and the first character of the value to see if they're the same.  That, or orchestrate things so that the matcher being used calls the  DocumentRegionEdgeMatcher, and when no match is found there, falls back upon the platform's implementation.
Comment 9 David Carver CLA 2008-05-23 09:40:13 EDT
This seems to be working in Web Tools 3.0 RC 1
Comment 10 Amy Wu CLA 2008-10-27 04:33:59 EDT
reassigning to inbox
Comment 11 Ian Tewksbury CLA 2010-04-05 14:12:35 EDT
(In reply to comment #9)
> This seems to be working in Web Tools 3.0 RC 1

This works for me as well in WTP 3.2.  Time to close.
Comment 12 Nick Sandonato CLA 2010-04-05 14:15:47 EDT
Looks like this has been implemented over time or as the result of another fix.