Synchronously read autocomplete related files

This commit is contained in:
James-Yu 2017-01-03 11:16:45 +08:00
parent 5df5343a60
commit 6de40d8097
4 changed files with 13 additions and 23 deletions

View File

@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.2] - 2017-01-03
### Changed
- Synchronously read related files when developing citation and reference autocompletes.
- The original acynchronous pattern will miss the latest changes.
- If the autocomplete reaction speed is greatly influenced in large files, this change may be reverted.
## [0.1.1] - 2017-01-01
### Added
- An extension icon.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -3,7 +3,7 @@
"displayName": "LaTeX Workshop",
"description": "AIO LaTeX extension to preview, compile, autocomplete, and more.",
"icon": "img/icon.png",
"version": "0.1.1",
"version": "0.1.2",
"publisher": "James-Yu",
"license": "MIT",
"homepage": "https://github.com/James-Yu/LaTeX-Workshop",

View File

@ -24,17 +24,9 @@ export function find_citation_keys() {
while (bib = reg.exec(text)) {
var file = path.join(path.dirname(vscode.window.activeTextEditor.document.uri.fsPath), path.basename(bib[1], '.bib') + '.bib')
if (!fs.existsSync(file)) continue;
if (latex_data.get_citation_keys().length == 0) {
var buffer = fs.readFileSync(file);
parse_keys(buffer);
latex_data.set_citation_keys(keys);
} else {
fs.readFile(file, (err, data) => {
if (err) return;
parse_keys(data);
latex_data.set_citation_keys(keys);
})
}
var buffer = fs.readFileSync(file);
parse_keys(buffer);
latex_data.set_citation_keys(keys);
}
}
@ -63,16 +55,8 @@ export function find_label_keys() {
}
}
}
if (latex_data.get_label_keys().length == 0) {
var buffer = fs.readFileSync(aux_file);
parse_keys(buffer);
latex_data.set_label_keys(keys);
} else {
fs.readFile(aux_file, (err, data) => {
if (err) return;
parse_keys(data);
latex_data.set_label_keys(keys);
})
}
var buffer = fs.readFileSync(aux_file);
parse_keys(buffer);
latex_data.set_label_keys(keys);
}
}