Fix line index rebuild during incremental changes
This commit is contained in:
parent
191abf3685
commit
7c1d5f286a
1 changed files with 5 additions and 5 deletions
|
|
@ -676,13 +676,13 @@ fn apply_document_changes(
|
|||
// remember the last valid line in the index and only rebuild it if needed.
|
||||
enum IndexValid {
|
||||
All,
|
||||
UpToLine(u64),
|
||||
UpToLineExclusive(u64),
|
||||
}
|
||||
|
||||
impl IndexValid {
|
||||
fn covers(&self, line: u64) -> bool {
|
||||
match *self {
|
||||
IndexValid::UpToLine(to) => to >= line,
|
||||
IndexValid::UpToLineExclusive(to) => to > line,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
|
@ -692,10 +692,10 @@ fn apply_document_changes(
|
|||
for change in content_changes {
|
||||
match change.range {
|
||||
Some(range) => {
|
||||
if !index_valid.covers(range.start.line) {
|
||||
if !index_valid.covers(range.end.line) {
|
||||
line_index = Cow::Owned(LineIndex::new(&old_text));
|
||||
}
|
||||
index_valid = IndexValid::UpToLine(range.start.line);
|
||||
index_valid = IndexValid::UpToLineExclusive(range.start.line);
|
||||
let range = range.conv_with(&line_index);
|
||||
let mut text = old_text.to_owned();
|
||||
match std::panic::catch_unwind(move || {
|
||||
|
|
@ -713,7 +713,7 @@ fn apply_document_changes(
|
|||
}
|
||||
None => {
|
||||
*old_text = change.text;
|
||||
index_valid = IndexValid::UpToLine(0);
|
||||
index_valid = IndexValid::UpToLineExclusive(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue