aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2020-05-04 18:04:30 +0100
committerLaurenČ›iu Nicola <[email protected]>2020-05-04 18:04:30 +0100
commit7c1d5f286a971484fc1f1d367e762853471873e4 (patch)
tree092c6ec57b56f2edfef7416981a8f68d2c5f248c /crates
parent191abf368563d6229c5e6025f7cde2e7d4c22ab0 (diff)
Fix line index rebuild during incremental changes
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 401fae755..b163ea848 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -676,13 +676,13 @@ fn apply_document_changes(
676 // remember the last valid line in the index and only rebuild it if needed. 676 // remember the last valid line in the index and only rebuild it if needed.
677 enum IndexValid { 677 enum IndexValid {
678 All, 678 All,
679 UpToLine(u64), 679 UpToLineExclusive(u64),
680 } 680 }
681 681
682 impl IndexValid { 682 impl IndexValid {
683 fn covers(&self, line: u64) -> bool { 683 fn covers(&self, line: u64) -> bool {
684 match *self { 684 match *self {
685 IndexValid::UpToLine(to) => to >= line, 685 IndexValid::UpToLineExclusive(to) => to > line,
686 _ => true, 686 _ => true,
687 } 687 }
688 } 688 }
@@ -692,10 +692,10 @@ fn apply_document_changes(
692 for change in content_changes { 692 for change in content_changes {
693 match change.range { 693 match change.range {
694 Some(range) => { 694 Some(range) => {
695 if !index_valid.covers(range.start.line) { 695 if !index_valid.covers(range.end.line) {
696 line_index = Cow::Owned(LineIndex::new(&old_text)); 696 line_index = Cow::Owned(LineIndex::new(&old_text));
697 } 697 }
698 index_valid = IndexValid::UpToLine(range.start.line); 698 index_valid = IndexValid::UpToLineExclusive(range.start.line);
699 let range = range.conv_with(&line_index); 699 let range = range.conv_with(&line_index);
700 let mut text = old_text.to_owned(); 700 let mut text = old_text.to_owned();
701 match std::panic::catch_unwind(move || { 701 match std::panic::catch_unwind(move || {
@@ -713,7 +713,7 @@ fn apply_document_changes(
713 } 713 }
714 None => { 714 None => {
715 *old_text = change.text; 715 *old_text = change.text;
716 index_valid = IndexValid::UpToLine(0); 716 index_valid = IndexValid::UpToLineExclusive(0);
717 } 717 }
718 } 718 }
719 } 719 }