Only count words in the current document on save

This commit is contained in:
Jerome Lelong 2022-01-12 17:09:07 +01:00
parent 4e7bbe1fc3
commit 0d2ddad1b5
3 changed files with 4 additions and 11 deletions

View File

@ -1581,7 +1581,7 @@
"never"
],
"enumDescriptions": [
"Count words in the LaTeX documents of the entire project from the root file",
"Count words in the current document",
"Never automatically call texcount"
],
"default": "never",

View File

@ -68,7 +68,7 @@ export class Counter {
}
}
async countOnSaveIfEnabled(file: string) {
countOnSaveIfEnabled(file: string) {
if (!this.autoRunEnabled) {
return
}
@ -79,14 +79,7 @@ export class Counter {
this.extension.logger.addLogMessage(`Auto texcount started on saving file: ${file}`)
this.disableCountAfterSave = true
setTimeout(() => this.disableCountAfterSave = false, this.autoRunInterval)
if (this.extension.manager.rootFile === undefined) {
await this.extension.manager.findRoot()
}
if (this.extension.manager.rootFile === undefined) {
this.extension.logger.addLogMessage('Cannot find root file')
return
}
void this.runTeXCount(this.extension.manager.rootFile).then(() => {
void this.runTeXCount(file).then(() => {
this.updateWordCount()
})
}

View File

@ -161,7 +161,7 @@ export function activate(context: vscode.ExtensionContext): ReturnType<typeof ge
void extension.manager.buildOnSave(e.fileName)
}
}
void extension.counter.countOnSaveIfEnabled(e.fileName)
extension.counter.countOnSaveIfEnabled(e.fileName)
}
}))