Fix anchor biases for completion replacement ranges (esp slash commands) (#32262)

Closes #32205

The issue was that in some places the end of the replacement range used
anchors with `Bias::Left` instead of `Bias::Right`. Before #31872
completions were recomputed on every change and so the anchor bias
didn't matter. After that change, the end anchor didn't move as the
user's typing. Changing it to `Bias::Right` to "stick" to the character
to the right of the cursor fixes this.

Release Notes:

- Fixes incorrect auto-completion of `/files` in text threads (Preview
Only)
This commit is contained in:
Michael Sloan 2025-06-06 14:54:00 -06:00 committed by GitHub
parent 51585e770d
commit e0057ccd0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 12 deletions

View file

@ -715,7 +715,7 @@ fn completion_replace_range(snapshot: &BufferSnapshot, anchor: &Anchor) -> Optio
if end_in_line > start_in_line {
let replace_start = snapshot.anchor_before(line_start + start_in_line);
let replace_end = snapshot.anchor_before(line_start + end_in_line);
let replace_end = snapshot.anchor_after(line_start + end_in_line);
Some(replace_start..replace_end)
} else {
None