Skip to content

refactor: pass the reverse insert mode to get_text_edit_range explicitly - #3066

Merged
rchl merged 1 commit into
mainfrom
refactor/opposite-insert-mode
Oct 11, 2026
Merged

rchl merged 1 commit into
mainfrom
refactor/opposite-insert-mode

Conversation

@rchl

@rchl rchl commented Oct 11, 2026

Copy link
Copy Markdown
Member

get_text_edit_range used to read LspCommitCompletionWithOppositeInsertMode.active itself, so it only picked the opposite insert mode while it happened to run inside lsp_commit_completion_with_opposite_insert_mode. That holds today because lsp_select_completion applies the completion synchronously from within commit_completion, but it breaks as soon as the edit is applied later, for example after resolving the completion item first.

lsp_select_completion now reads the flag when it starts, which is reliably inside commit_completion, and passes it to get_text_edit_range as a keyword-only reverse_insert_mode argument. LspCommitCompletionWithOppositeInsertMode still sets the flag around commit_completion and resets it afterwards, so it can't leak into a later completion. That matters for alt+enter on a non-LSP item, such as a word completion, where lsp_select_completion never runs.

There is no change in behavior. This is split out of the work on resolving completion items before applying them.

Assisted-By: Claude Code:claude-opus-5-5

lsp_select_completion runs synchronously from within commit_completion,
so it is the place where the LspCommitCompletionWithOppositeInsertMode
flag can be read reliably. Read it there and pass it on, instead of
having get_text_edit_range read the flag whenever it happens to be
called. This keeps the opposite insert mode working once the completion
is applied later, for example after resolving the completion item.

Assisted-By: Claude Code:claude-opus-5-5
@rchl

rchl commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

Something that doesn't matter today but it's the correct thing to do and will matter if we go with #2632

@rchl

rchl commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

This is a trivial change that does not change any behavior so not waiting for review.

@rchl
rchl merged commit f8a4f95 into main Oct 11, 2026
8 of 9 checks passed
@rchl
rchl deleted the refactor/opposite-insert-mode branch October 11, 2026 16:35
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.

1 participant