Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 2ff1669

Browse files
committed
Reset version number count on file open
1 parent 10bbc1c commit 2ff1669

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/actions/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ impl InitActionContext {
262262
}
263263

264264
fn check_change_version(&self, file_path: &Path, version_num: u64) {
265-
let mut prev_changes = self.prev_changes.lock().unwrap();
266265
let file_path = file_path.to_owned();
266+
let mut prev_changes = self.prev_changes.lock().unwrap();
267267

268268
if prev_changes.contains_key(&file_path) {
269269
let prev_version = prev_changes[&file_path];
@@ -273,6 +273,12 @@ impl InitActionContext {
273273
prev_changes.insert(file_path, version_num);
274274
}
275275

276+
fn reset_change_version(&self, file_path: &Path) {
277+
let file_path = file_path.to_owned();
278+
let mut prev_changes = self.prev_changes.lock().unwrap();
279+
prev_changes.remove(&file_path);
280+
}
281+
276282
fn convert_pos_to_span(&self, file_path: PathBuf, pos: Position) -> Span {
277283
trace!("convert_pos_to_span: {:?} {:?}", file_path, pos);
278284

src/actions/notifications.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl BlockingNotificationAction for DidOpenTextDocument {
6969
trace!("on_open: {:?}", params.text_document.uri);
7070
let ctx = ctx.inited();
7171
let file_path = parse_file_path!(&params.text_document.uri, "on_open")?;
72-
72+
ctx.reset_change_version(&file_path);
7373
ctx.vfs.set_file(&file_path, &params.text_document.text);
7474
Ok(())
7575
}

0 commit comments

Comments
 (0)