Aptana Studio
  1. Aptana Studio
  2. APSTUD-2963

Scope Selector doesn't match when segments are between compound segments in scope

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: High High
    • Resolution: Fixed
    • Affects Version/s: Aptana Studio 3.0.3
    • Fix Version/s: Aptana Studio 3.0.4
    • Component/s: None
    • Labels:
      None

      Description

      Scope selectors aren't matching TM behavior again.

      Specifically, a scope selector of "text source" should match against "text.haml meta.line.ruby.haml source.ruby.embedded.haml", but does not. I think we're getting thrown by the meta scope in between.

      I saw this in comparing HAML in the Twilight theme between us and Textmate.

        Issue Links

          Activity

          Hide
          Chris Williams added a comment -

          Textmate's rendering

          Show
          Chris Williams added a comment - Textmate's rendering
          Hide
          Chris Williams added a comment -

          Our incorrect rendering

          Show
          Chris Williams added a comment - Our incorrect rendering
          Hide
          Chris Williams added a comment -

          Here is a JUnit test case for ScopeSelectorTests that exposes the issue:

          public void testMatchWhenScopeHasSegmentsBetweenScopeSelectorSegments()
          	{
          		ScopeSelector textSourceSelector = new ScopeSelector("text source");
          		assertTrue(
          				"Selector should match, but doesn't", textSourceSelector
          				.matches("text.haml meta.line.ruby.haml source.ruby.embedded.haml comment.line.number-sign.ruby"));
          		assertTrue("Selector should match, but doesn't", textSourceSelector.matches("text.haml meta.line.ruby.haml source.ruby.embedded.haml"));
          	}
          
          Show
          Chris Williams added a comment - Here is a JUnit test case for ScopeSelectorTests that exposes the issue: public void testMatchWhenScopeHasSegmentsBetweenScopeSelectorSegments() { ScopeSelector textSourceSelector = new ScopeSelector("text source"); assertTrue( "Selector should match, but doesn't", textSourceSelector .matches("text.haml meta.line.ruby.haml source.ruby.embedded.haml comment.line.number-sign.ruby")); assertTrue("Selector should match, but doesn't", textSourceSelector.matches("text.haml meta.line.ruby.haml source.ruby.embedded.haml")); }
          Hide
          Kevin Lindsey added a comment -

          Just an implementation note. This will require roughly N^2 comparisons, worst case. I'm wondering if we could convert the selector to a regex and then perform a regex match instead of using our nested loops. That would have to be a lot faster. For example (and simplifying things a bit), the above selector could look like the following regex, where whitespace is ignored:

          ^
          .*
          \b(text(\.[a-z]+)*)(\b|$)
          .*
          \b(source(\.[a-z]+)*)(\b|$)
          .*
          $
          
          Show
          Kevin Lindsey added a comment - Just an implementation note. This will require roughly N^2 comparisons, worst case. I'm wondering if we could convert the selector to a regex and then perform a regex match instead of using our nested loops. That would have to be a lot faster. For example (and simplifying things a bit), the above selector could look like the following regex, where whitespace is ignored: ^ .* \b(text(\.[a-z]+)*)(\b|$) .* \b(source(\.[a-z]+)*)(\b|$) .* $
          Show
          Chris Williams added a comment - Fixed on development: https://github.com/aptana/studio3/commit/5df2665a677e02c28e321c470079c12de34c18c9 Cherry-picked to master: https://github.com/aptana/studio3/commit/15c221e7e7d57eb97aa260f6afe701a869dead61
          Hide
          Clayton Headley (Inactive) added a comment -

          Verified in Titanium Studio, build: 2.2.0.201207302015. Closing ticket.

          Show
          Clayton Headley (Inactive) added a comment - Verified in Titanium Studio, build: 2.2.0.201207302015. Closing ticket.

            People

            • Assignee:
              Chris Williams
              Reporter:
              Chris Williams
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: