gemini-cli - 💡(How to fix) Fix Bug: vim cc is a no-op on non-last and astral-character lines [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

vim_change_line computes the replacement range through offset helpers that include a trailing newline for non-last lines and measure columns in UTF-16 code units. The resulting end column can be one past the code-point length of the line, or can split a surrogate pair. replaceRangeInternal rejects that invalid range and returns the original state unchanged.

Fix Action

Fixed

Code Example

before: cc -> ['hello world', 'foo']
after:  cc -> ['', 'foo']
RAW_BUFFERClick to expand / collapse

What happened?

Vim cc (vim_change_line) silently does nothing in several cases:

  • when the cursor is on any non-last line of a multi-line buffer;
  • when the current line contains an astral character, such as an emoji; and
  • when using a count such as 2cc across multiple lines.

The UI still switches to INSERT mode, but the target line(s) remain unchanged.

What did you expect to happen?

cc should clear the current line and enter insert mode, including when the line is not the final buffer line. It should also handle astral characters by measuring line length in code points rather than UTF-16 code units.

For example, with ['hello world', 'foo'] and the cursor on line 0:

before: cc -> ['hello world', 'foo']
after:  cc -> ['', 'foo']

Root cause

vim_change_line computes the replacement range through offset helpers that include a trailing newline for non-last lines and measure columns in UTF-16 code units. The resulting end column can be one past the code-point length of the line, or can split a surrogate pair. replaceRangeInternal rejects that invalid range and returns the original state unchanged.

Proposed fix

Compute the range directly in code points: from column 0 of the first changed line to the code-point length of the last changed line. Add regression coverage for non-last lines, emoji, and multi-count cc.

Related PR: #27554

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix Bug: vim cc is a no-op on non-last and astral-character lines [1 pull requests]