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:
parent
51585e770d
commit
e0057ccd0f
4 changed files with 20 additions and 12 deletions
|
@ -5067,10 +5067,16 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
let multibuffer_snapshot = self.buffer.read(cx).read(cx);
|
||||
|
||||
// Typically `start` == `end`, but with snippet tabstop choices the default choice is
|
||||
// inserted and selected. To handle that case, the start of the selection is used so that
|
||||
// the menu starts with all choices.
|
||||
let position = self.selections.newest_anchor().start;
|
||||
let position = self
|
||||
.selections
|
||||
.newest_anchor()
|
||||
.start
|
||||
.bias_right(&multibuffer_snapshot);
|
||||
if position.diff_base_anchor.is_some() {
|
||||
return;
|
||||
}
|
||||
|
@ -5083,8 +5089,9 @@ impl Editor {
|
|||
let buffer_snapshot = buffer.read(cx).snapshot();
|
||||
|
||||
let query: Option<Arc<String>> =
|
||||
Self::completion_query(&self.buffer.read(cx).read(cx), position)
|
||||
.map(|query| query.into());
|
||||
Self::completion_query(&multibuffer_snapshot, position).map(|query| query.into());
|
||||
|
||||
drop(multibuffer_snapshot);
|
||||
|
||||
let provider = match requested_source {
|
||||
Some(CompletionsMenuSource::Normal) | None => self.completion_provider.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue