-
Notifications
You must be signed in to change notification settings - Fork 27
Swarm Fix: [BUG] [v1.1.0] VimMode: r (replace char) ignores numeric count — always replaces exactly one column #38022
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| To fix the issue, you need to apply the `count` value to widen the range in the `r + next-character` flow. Here's the exact code fix: | ||
|
|
||
| ```typescript | ||
| // In VimMode.tsx, replace the lines 1854-1863 with the following code: | ||
| if (info.key === 'r') { | ||
| const count = vim.getEffectiveCount(); | ||
| const range = new monaco.Range( | ||
| info.lineNumber, | ||
| info.column, | ||
| info.lineNumber, | ||
| Math.min(info.column + count, editor.getModel().getLineMaxColumn(info.lineNumber)) | ||
| ); | ||
| editor.executeEdits('vim-replace', [ | ||
| { | ||
| range, | ||
| text: nextChar, | ||
| }, | ||
| ]); | ||
| setLastChange({ range, count }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Persist the applied count, not the requested count. At Line 19, storing 🤖 Prompt for AI Agents |
||
| } | ||
| ``` | ||
|
|
||
| This code applies the `count` value to widen the range, replacing the specified number of characters. The `Math.min` function ensures that the replacement does not exceed the end of the line. The `setLastChange` function is also updated to reflect the correct count. | ||
|
Comment on lines
+1
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR currently ships a proposal, not the bug fix implementation. Line 1 through Line 23 only add guidance text in 🧰 Tools🪛 LanguageTool[style] ~1-~1: Consider using a different verb for a more formal wording. (FIX_RESOLVE) 🤖 Prompt for AI Agents |
||
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.
🧩 Analysis chain
🌐 Web query:
In Monaco Editor, when executeEdits replaces a range of N characters with a 1-character string, does it collapse the text length to 1? Please cite the official Monaco API/docs for ICodeEditor.executeEdits behavior.💡 Result:
Yes, in Monaco Editor, when ICodeEditor.executeEdits replaces a range of N characters with a 1-character string, it replaces the entire range with exactly that 1-character string, collapsing the text length in that range to 1 character (net change of 1 - N characters).
Citations:
Use
nextChar.repeat(actualCount)to preserve replacement width with multi-character ranges.When
executeEditsreplaces a range spanning multiple columns with a single character, Monaco Editor collapses the text length to 1 character. For Vim'srcommand with count, each matched character should be replaced individually, not collapsed. Calculate the actual replacement count and repeat the character accordingly.Suggested patch
🤖 Prompt for AI Agents