-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
Instead of throwing an error could we do something a bit more sensible? Rest of the code looks good though. :) |
src/cmd_line/commands/substitute.ts
Outdated
const prevSearchState = vimState.globalState.searchState; | ||
if (prevSearchState === undefined || prevSearchState.searchString === '') { | ||
// Should we use VimError (in src/error.ts) ? | ||
throw new Error('Empty search string!'); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/cmd_line/commands/substitute.ts
Outdated
const prevSearchState = vimState.globalState.searchState; | ||
if (prevSearchState === undefined || prevSearchState.searchString === '') { | ||
throw VimError.fromCode(ErrorCode.E35); | ||
// throw new Error('Empty search string!'); |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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?
@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? |
Thanks for filing #2525 and your contribution. |
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: