Repository navigation
Conversation
A typed <Esc> exits visual mode from handleEsc in findKey, outside a vim operation. The cursor move in exitVisualMode then reports cursor activity, handleExternalSelection sees visual mode over an empty selection and exits visual mode itself, recording the last selection with its linewise or blockwise flags. Back in the outer exitVisualMode, updateLastSelection ran again after those flags were cleared, so `V j <Esc> gv` and `<C-v> j l <Esc> gv` reselected charwise. An exit that the cursor move already made now returns before recording again. The existing reselect tests leave visual mode by toggling V or <C-v>, which never takes this path; two tests leave it with <Esc>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W2aBHqJtz3wmW7kAdNmsYS
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
V j <Esc> gvreselects a charwise selection instead of a linewise one. The same happens to<C-v> ... <Esc> gv, which reselects charwise instead of blockwise.Cause. A typed
<Esc>exits visual mode fromhandleEscinsidefindKey, outside a vim operation. ThesetCursorinexitVisualModethen reports cursor activity.handleExternalSelectionsees visual mode over an empty selection and callsexitVisualMode(cm, false), which records the last selection with itsvisualLine/visualBlockflags and clears them. Back in the outer call,updateLastSelectionruns again with the flags already false, overwriting the correct record.It shows up when vim handles
<Esc>itself, for example withPrec.highest(vim()). With vim at default precedence, CodeMirror's own Escape binding collapses the selection first and only the inner exit runs.Fix.
exitVisualModereturns before recording again when the cursor move already ended visual mode.Tests. The existing
reselect_visual_lineandreselect_visual_blocktests leave visual mode by togglingV/<C-v>, which never takes this path. Two new tests leave it with<Esc>. Both fail without the fix, and the full suite passes with it.🤖 Generated with Claude Code
https://claude.ai/code/session_01W2aBHqJtz3wmW7kAdNmsYS