Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITextModel.findMatches is incorrect in this case #80707

Closed
alexdima opened this issue Sep 11, 2019 · 2 comments
Closed

ITextModel.findMatches is incorrect in this case #80707

alexdima opened this issue Sep 11, 2019 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-textbuffer Editor text buffer verified Verification succeeded
Milestone

Comments

@alexdima
Copy link
Member

  • create a new file
  • type bar
  • do shift+alt+down 5 times (to duplicate line down 5 times)
  • click on one of the duplicated lines
  • observe that the first instance is not highlighted due to findMatches being incorrect

image

If you do a reload (the text buffer is read from disk) the issue does not reproduce:

image

@alexdima alexdima added the editor-textbuffer Editor text buffer label Sep 11, 2019
@alexdima alexdima added the bug Issue identified by VS Code Team member as probable bug label Oct 1, 2019
@rebornix rebornix added this to the October 2019 milestone Oct 23, 2019
@rebornix
Copy link
Member

🚀 Really good catch! I definitely saw it a couple of times but didn't find good ways to reproduce it.

The root cause is we didn't respect how Searcher validates the search result. If word patterns are provided, we will check if the search result is inside a pair of word boundaries. However in above case, we attempt to search /bar/gu in barbar\nbar\nbar\nbar\nbar\n from offset 3. The first result is [3, 6) but Searcher thinks it's invalid as it's part of word barbar\n.

@rebornix
Copy link
Member

Verify:

1st, the same as what @alexandrudima described:

  • Open an untiled file
  • Type bar
  • shift+alt+down 5 times
  • move the cursor to left once
  • all bar should be highlighted

2nd. Finish above steps first

  • add 2 at the end of bar of the 4th line
  • add 2 at the end of bar of the 2nd line
  • Please verify
    • move cursor into any bar highlights all bar
    • move cursor into any bar2 highlights all bar2 but no bar
    • open find widget, search bar w or w/o Toggle Whole Word works as expected.

@rebornix rebornix added the verified Verification succeeded label Oct 24, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-textbuffer Editor text buffer verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

2 participants