Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Adds option for strongly preferred prefix and single segment search. #3588

Merged
merged 6 commits into from
May 14, 2013

Conversation

dangoor
Copy link
Contributor

@dangoor dangoor commented Apr 24, 2013

These options make stringMatch produce useful and predictable results in cases that are not
quite the same as file searching (such as code hinting).

These options make stringMatch produce useful and predictable results in cases that are not
quite the same as file searching (such as code hinting).
Adding this option to string matching provides a fix for #3534 by putting
the matches at the same score and using the scope as a tie breaker.
@dangoor
Copy link
Contributor Author

dangoor commented Apr 25, 2013

@peterflynn I'd like to get this in for sprint 24 as it takes care of #3534.

@peterflynn
Copy link
Member

Reviewing

* @return {{ranges:Array.<{text:string, matched:boolean, includesLastSegment:boolean}>, matchGoodness:int, scoreDebug: Object}} matched ranges and score
*/
function stringMatch(str, query, special) {
function stringMatch(str, query, options, special) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is public API, so it would be better to add the new arg at the end for backwards compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're probably right, though I made this choice because the special parameter is just a speed optimization used by StringMatcher and is not likely used elsewhere. options, on the other hand, is likely to be used.

I could keep the new signature and deprecate the old by looking for the presence of special.specials. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point -- in light of that, it's fine by me as-is

@peterflynn
Copy link
Member

Done reviewing body code -- will review unit test part after I grab lunch

expect(result.stringRanges[0]).toEqual(
{ text: "str", matched: true, includesLastSegment: true }
);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a test for singleSegmentSearch used in isolation? Although core code doesn't do that (yet), it is exposed in the API...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

@peterflynn
Copy link
Member

@dangoor Done reviewing

...and some other small changes based on review feedback
@dangoor
Copy link
Contributor Author

dangoor commented Apr 25, 2013

I'm going to remove the sprint 24 flag from this. I'd like for this change to get in properly, and if it's sprint 25 that's fine.

@peterflynn
Copy link
Member

Looking pretty good. I think the only things remaining are:

  • Should plugins be able to pass matcher options too?
  • Should singleSegmentSearch be on by default?
  • Various comments on unit tests
  • Should singleSegmentSearch be renamed?

@peterflynn
Copy link
Member

Oh also -- do you want to include a change in the JavaScriptCodeHints extension to use this flag?

@njx
Copy link
Contributor

njx commented May 3, 2013

Looks like this could fix #3643.

@peterflynn
Copy link
Member

Nominated pull request for Sprint 25 -- added to card in Trello

Conflicts:
	src/extensions/default/JavaScriptCodeHints/main.js
…aults to false

(which is a change in behavior for quick navigate that should actually be fine for
those uses). Also augmented the test cases based on review feedback.
@dangoor
Copy link
Contributor Author

dangoor commented May 13, 2013

@peterflynn I've renamed singleSegmentSearch to segmentedSearch (and flipped the meaning with the default being "false", so now Quick Open for files explicitly sets this).

JS Code Hints does set the prefixPrefixMatches option.

I think I've addressed all review comments except for allowing the match options to be passed in via pluginDef. I can't take care of that right this second, but I will do so either this evening or tomorrow morning.

@peterflynn
Copy link
Member

@dangoor Changes look perfect so far! Let me know when the last bit is in...

@dangoor
Copy link
Contributor Author

dangoor commented May 14, 2013

OK, I just pushed the last part. Quick Open plugins can now include matcherOptions.

@peterflynn
Copy link
Member

Awesome! Merging...

I'll also add a placeholder to the release notes for the API enhancements.

peterflynn added a commit that referenced this pull request May 14, 2013
Add QuickOpen / StringMatch options for strongly preferred prefix and unsegmented search weighting.
@peterflynn peterflynn merged commit 9aba45c into master May 14, 2013
@peterflynn peterflynn deleted the dangoor/prefer-prefix branch May 14, 2013 22:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants