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

Commit

Permalink
Reset version number count on file open
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Mar 28, 2018
1 parent 10bbc1c commit 2ff1669
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ impl InitActionContext {
}

fn check_change_version(&self, file_path: &Path, version_num: u64) {
let mut prev_changes = self.prev_changes.lock().unwrap();
let file_path = file_path.to_owned();
let mut prev_changes = self.prev_changes.lock().unwrap();

if prev_changes.contains_key(&file_path) {
let prev_version = prev_changes[&file_path];
Expand All @@ -273,6 +273,12 @@ impl InitActionContext {
prev_changes.insert(file_path, version_num);
}

fn reset_change_version(&self, file_path: &Path) {
let file_path = file_path.to_owned();
let mut prev_changes = self.prev_changes.lock().unwrap();
prev_changes.remove(&file_path);
}

fn convert_pos_to_span(&self, file_path: PathBuf, pos: Position) -> Span {
trace!("convert_pos_to_span: {:?} {:?}", file_path, pos);

Expand Down
2 changes: 1 addition & 1 deletion src/actions/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl BlockingNotificationAction for DidOpenTextDocument {
trace!("on_open: {:?}", params.text_document.uri);
let ctx = ctx.inited();
let file_path = parse_file_path!(&params.text_document.uri, "on_open")?;

ctx.reset_change_version(&file_path);
ctx.vfs.set_file(&file_path, &params.text_document.text);
Ok(())
}
Expand Down

0 comments on commit 2ff1669

Please sign in to comment.