Fix invalid access to deleted line when updating insert completion
The computation of the completion end position was taking place too early, before we checked if the buffer did get modified. Fixes #3349
This commit is contained in:
parent
31caae20eb
commit
7545fa58ae
|
@ -267,12 +267,6 @@ InsertCompletion complete_option(const SelectionList& sels,
|
||||||
str_to_int({match[2].first, match[2].second}) - 1 };
|
str_to_int({match[2].first, match[2].second}) - 1 };
|
||||||
if (not buffer.is_valid(coord))
|
if (not buffer.is_valid(coord))
|
||||||
return {};
|
return {};
|
||||||
auto end = cursor_pos;
|
|
||||||
if (match[3].matched)
|
|
||||||
{
|
|
||||||
ByteCount len = str_to_int({match[3].first, match[3].second});
|
|
||||||
end = buffer.advance(coord, len);
|
|
||||||
}
|
|
||||||
size_t timestamp = (size_t)str_to_int({match[4].first, match[4].second});
|
size_t timestamp = (size_t)str_to_int({match[4].first, match[4].second});
|
||||||
auto changes = buffer.changes_since(timestamp);
|
auto changes = buffer.changes_since(timestamp);
|
||||||
if (any_of(changes, [&](auto&& change) { return change.begin < coord; }))
|
if (any_of(changes, [&](auto&& change) { return change.begin < coord; }))
|
||||||
|
@ -327,6 +321,12 @@ InsertCompletion complete_option(const SelectionList& sels,
|
||||||
std::pop_heap(first, last--, greater);
|
std::pop_heap(first, last--, greater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto end = cursor_pos;
|
||||||
|
if (match[3].matched)
|
||||||
|
{
|
||||||
|
ByteCount len = str_to_int({match[3].first, match[3].second});
|
||||||
|
end = buffer.advance(coord, len);
|
||||||
|
}
|
||||||
return { std::move(candidates), coord, end, timestamp };
|
return { std::move(candidates), coord, end, timestamp };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
test/regression/3349-crash-in-completion/cmd
Normal file
1
test/regression/3349-crash-in-completion/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
gei<c-n><backspace><backspace>
|
2
test/regression/3349-crash-in-completion/in
Normal file
2
test/regression/3349-crash-in-completion/in
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
first
|
||||||
|
a
|
1
test/regression/3349-crash-in-completion/out
Normal file
1
test/regression/3349-crash-in-completion/out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
first
|
4
test/regression/3349-crash-in-completion/rc
Normal file
4
test/regression/3349-crash-in-completion/rc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
set-option global autocomplete insert
|
||||||
|
declare-option -hidden completions my_completions
|
||||||
|
set-option global completers option=my_completions
|
||||||
|
set-option global my_completions "2.1+1@%val(timestamp)" "a||a"
|
2
test/regression/3349-crash-in-completion/script
Normal file
2
test/regression/3349-crash-in-completion/script
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ui_out -ignore 4
|
||||||
|
sleep .2 # trigger insert completion auto update
|
Loading…
Reference in New Issue
Block a user