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

bug: fixes behaviour of search when using * and # (fixes #2517) #2518

Merged
merged 5 commits into from
Apr 10, 2018
Merged

bug: fixes behaviour of search when using * and # (fixes #2517) #2518

merged 5 commits into from
Apr 10, 2018

Conversation

clamb
Copy link
Contributor

@clamb clamb commented Apr 6, 2018

What this PR does / why we need it:
Make VSCodeVim behaves more like Vim with regards to * and #.

Which issue(s) this PR fixes
#2517

Special notes for your reviewer:

@johnfn
Copy link
Member

johnfn commented Apr 7, 2018

Instead of throwing an error could we do something a bit more sensible? Rest of the code looks good though. :)

@clamb
Copy link
Contributor Author

clamb commented Apr 7, 2018

Vim throws an error when the search pattern is empty, that's why I implemented the same behavior.

animated

const prevSearchState = vimState.globalState.searchState;
if (prevSearchState === undefined || prevSearchState.searchString === '') {
// Should we use VimError (in src/error.ts) ?
throw new Error('Empty search string!');
Copy link
Member

Choose a reason for hiding this comment

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

Can you implement and throw the VimError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried, but the handling of VimError is either broken or, more likely, I don't understand how it works.

Whenever a VimError is thrown, StatusBarImpl.setText is invoked with the text given to VimError (commandLine.ts), but is then immediately invoked again with "-- NORMAL -- :" and again with "-- NORMAL -- " as text. Therefore, the user does not get a chance to see the error thrown by VimError.

animated

Copy link
Member

Choose a reason for hiding this comment

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

That looks to be a separate bug with how we are handling thrown VimErrors. We can either fix it in your PR here, or considering there's no behaviour change, we can merge your PR and file a subsequent issue to fix it later

const prevSearchState = vimState.globalState.searchState;
if (prevSearchState === undefined || prevSearchState.searchString === '') {
throw VimError.fromCode(ErrorCode.E35);
// throw new Error('Empty search string!');
Copy link
Member

Choose a reason for hiding this comment

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

Remove this comment

src/error.ts Outdated
37: 'No write since last change (add ! to override)',
208: 'Error writing to file',
348: 'No string under cursor',
444: 'Cannot close last window',
476: 'Invalid command',
Copy link
Member

Choose a reason for hiding this comment

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

Are we using this somewhere?

@jpoon
Copy link
Member

jpoon commented Apr 10, 2018

@clamb one more thing before we merge, can you file a new issue to track the fact that the error doesn't show up on the status bar?

@jpoon
Copy link
Member

jpoon commented Apr 10, 2018

Thanks for filing #2525 and your contribution.

@jpoon jpoon merged commit 52165bf into VSCodeVim:master Apr 10, 2018
@jpoon jpoon changed the title fixes #2517 bug: fixes behaviour of search when using * and # (fixes #2517) Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants