Fuzzy-match lines when applying edits from the assistant (#12056)
This uses Jaro-Winkler similarity for now, which seemed to produce pretty good results in my tests. We can easily swap it with something else if needed. Release Notes: - N/A
This commit is contained in:
parent
0b8c1680fb
commit
3a79aa85f4
4 changed files with 104 additions and 75 deletions
|
@ -3058,9 +3058,9 @@ impl ConversationEditor {
|
|||
.entry(buffer)
|
||||
.or_insert(Vec::<(Range<language::Anchor>, _)>::new());
|
||||
for suggestion in suggestions {
|
||||
let ranges =
|
||||
fuzzy_search_lines(snapshot.as_rope(), &suggestion.old_text);
|
||||
if let Some(range) = ranges.first() {
|
||||
if let Some(range) =
|
||||
fuzzy_search_lines(snapshot.as_rope(), &suggestion.old_text)
|
||||
{
|
||||
let edit_start = snapshot.anchor_after(range.start);
|
||||
let edit_end = snapshot.anchor_before(range.end);
|
||||
if let Err(ix) = edits.binary_search_by(|(range, _)| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue