parent
03f02804e5
commit
24bc9fd0a0
1 changed files with 10 additions and 17 deletions
|
@ -5,7 +5,7 @@ use super::{
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use dap::OutputEvent;
|
use dap::OutputEvent;
|
||||||
use editor::{CompletionProvider, Editor, EditorElement, EditorStyle, ExcerptId};
|
use editor::{Bias, CompletionProvider, Editor, EditorElement, EditorStyle, ExcerptId};
|
||||||
use fuzzy::StringMatchCandidate;
|
use fuzzy::StringMatchCandidate;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
Context, Entity, FocusHandle, Focusable, Render, Subscription, Task, TextStyle, WeakEntity,
|
Context, Entity, FocusHandle, Focusable, Render, Subscription, Task, TextStyle, WeakEntity,
|
||||||
|
@ -401,28 +401,21 @@ impl ConsoleQueryBarCompletionProvider {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or(&completion.label)
|
.unwrap_or(&completion.label)
|
||||||
.to_owned();
|
.to_owned();
|
||||||
let mut word_bytes_length = 0;
|
let buffer_text = snapshot.text();
|
||||||
for chunk in snapshot
|
let buffer_bytes = buffer_text.as_bytes();
|
||||||
.reversed_chunks_in_range(language::Anchor::MIN..buffer_position)
|
let new_bytes = new_text.as_bytes();
|
||||||
{
|
|
||||||
let mut processed_bytes = 0;
|
|
||||||
if let Some(_) = chunk.chars().rfind(|c| {
|
|
||||||
let is_whitespace = c.is_whitespace();
|
|
||||||
if !is_whitespace {
|
|
||||||
processed_bytes += c.len_utf8();
|
|
||||||
}
|
|
||||||
|
|
||||||
is_whitespace
|
let mut prefix_len = 0;
|
||||||
}) {
|
for i in (0..new_bytes.len()).rev() {
|
||||||
word_bytes_length += processed_bytes;
|
if buffer_bytes.ends_with(&new_bytes[0..i]) {
|
||||||
|
prefix_len = i;
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
word_bytes_length += chunk.len();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let buffer_offset = buffer_position.to_offset(&snapshot);
|
let buffer_offset = buffer_position.to_offset(&snapshot);
|
||||||
let start = buffer_offset - word_bytes_length;
|
let start = buffer_offset - prefix_len;
|
||||||
|
let start = snapshot.clip_offset(start, Bias::Left);
|
||||||
let start = snapshot.anchor_before(start);
|
let start = snapshot.anchor_before(start);
|
||||||
let replace_range = start..buffer_position;
|
let replace_range = start..buffer_position;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue