diff --git a/crates/agent/src/context_picker/completion_provider.rs b/crates/agent/src/context_picker/completion_provider.rs index 8d93838be67a9ec528a65cf577c9e427d50b90b4..4d147161c98f13bc9c76f6c94ac3e25dbc3d1d80 100644 --- a/crates/agent/src/context_picker/completion_provider.rs +++ b/crates/agent/src/context_picker/completion_provider.rs @@ -767,7 +767,7 @@ impl CompletionProvider for ContextPickerCompletionProvider { let snapshot = buffer.read(cx).snapshot(); let source_range = snapshot.anchor_before(state.source_range.start) - ..snapshot.anchor_before(state.source_range.end); + ..snapshot.anchor_after(state.source_range.end); let thread_store = self.thread_store.clone(); let text_thread_store = self.text_thread_store.clone(); diff --git a/crates/assistant_context_editor/src/slash_command.rs b/crates/assistant_context_editor/src/slash_command.rs index 4c34e94e6e71da141f52958b301f83d8f2b8377b..33b4bab37456c47616119faf5a2265be84b88286 100644 --- a/crates/assistant_context_editor/src/slash_command.rs +++ b/crates/assistant_context_editor/src/slash_command.rs @@ -240,13 +240,14 @@ impl SlashCommandCompletionProvider { Ok(vec![project::CompletionResponse { completions, - is_incomplete: false, + // TODO: Could have slash commands indicate whether their completions are incomplete. + is_incomplete: true, }]) }) } else { Task::ready(Ok(vec![project::CompletionResponse { completions: Vec::new(), - is_incomplete: false, + is_incomplete: true, }])) } } @@ -275,17 +276,17 @@ impl CompletionProvider for SlashCommandCompletionProvider { position.row, call.arguments.last().map_or(call.name.end, |arg| arg.end) as u32, ); - let command_range = buffer.anchor_after(command_range_start) + let command_range = buffer.anchor_before(command_range_start) ..buffer.anchor_after(command_range_end); let name = line[call.name.clone()].to_string(); let (arguments, last_argument_range) = if let Some(argument) = call.arguments.last() { let last_arg_start = - buffer.anchor_after(Point::new(position.row, argument.start as u32)); + buffer.anchor_before(Point::new(position.row, argument.start as u32)); let first_arg_start = call.arguments.first().expect("we have the last element"); - let first_arg_start = - buffer.anchor_after(Point::new(position.row, first_arg_start.start as u32)); + let first_arg_start = buffer + .anchor_before(Point::new(position.row, first_arg_start.start as u32)); let arguments = call .arguments .into_iter() @@ -298,7 +299,7 @@ impl CompletionProvider for SlashCommandCompletionProvider { ) } else { let start = - buffer.anchor_after(Point::new(position.row, call.name.start as u32)); + buffer.anchor_before(Point::new(position.row, call.name.start as u32)); (None, start..buffer_position) }; diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 06cdc68ce6ba8e75e680dc91a118e640a2cffb4a..75c9dfd4e275111a49b302de5907b5909216f3dd 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5046,7 +5046,13 @@ impl Editor { return; } - let position = self.selections.newest_anchor().head(); + let multibuffer_snapshot = self.buffer.read(cx).read(cx); + + let position = self + .selections + .newest_anchor() + .head() + .bias_right(&multibuffer_snapshot); if position.diff_base_anchor.is_some() { return; } @@ -5059,8 +5065,9 @@ impl Editor { let buffer_snapshot = buffer.read(cx).snapshot(); let query: Option> = - 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(), diff --git a/crates/inspector_ui/src/div_inspector.rs b/crates/inspector_ui/src/div_inspector.rs index 8b4b7966801c2d609f7088fc57ba6648bae57068..17ed6f556fff7647a281f3daac97935c19b38adb 100644 --- a/crates/inspector_ui/src/div_inspector.rs +++ b/crates/inspector_ui/src/div_inspector.rs @@ -726,7 +726,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