Skip to content

Commit b58bc13

Browse files
committed
#4247 Fix racing build-on-save when multiple files are edited
1 parent 12c3ff6 commit b58bc13

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/compile/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function autoBuild(file: string, type: 'onFileChange' | 'onSave', bibChanged: bo
4040
logger.log('Autobuild temporarily disabled.')
4141
return
4242
}
43+
lw.compile.lastAutoBuildTime = Date.now()
4344
if (!bibChanged && lw.root.subfiles.path && configuration.get('latex.rootFile.useSubFile')) {
4445
return build(true, lw.root.subfiles.path, lw.root.subfiles.langId)
4546
} else {
@@ -57,7 +58,7 @@ function autoBuild(file: string, type: 'onFileChange' | 'onSave', bibChanged: bo
5758
*/
5859
function canAutoBuild(): boolean {
5960
const configuration = vscode.workspace.getConfiguration('latex-workshop', lw.root.file.path ? vscode.Uri.file(lw.root.file.path) : undefined)
60-
return Date.now() - lw.compile.lastBuildTime >= (configuration.get('latex.autoBuild.interval', 1000) as number)
61+
return Date.now() - lw.compile.lastAutoBuildTime >= (configuration.get('latex.autoBuild.interval', 1000) as number)
6162
}
6263

6364
let isBuilding = false
@@ -147,7 +148,6 @@ async function buildLoop() {
147148

148149
isBuilding = true
149150
lw.compile.compiledPDFWriting++
150-
lw.compile.lastBuildTime = Date.now()
151151
// Stop watching the PDF file to avoid reloading the PDF viewer twice.
152152
// The builder will be responsible for refreshing the viewer.
153153
let skipped = true

src/compile/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const compile = {
88
autoBuild,
99
terminate,
1010
lastSteps: [] as Step[],
11-
lastBuildTime: 0,
11+
lastAutoBuildTime: 0,
1212
compiledPDFPath: '',
1313
compiledPDFWriting: 0,
1414
process: undefined as ChildProcessWithoutNullStreams | undefined

src/core/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ export function texdocUsepackages() {
445445
}
446446

447447
export async function saveActive() {
448-
lw.compile.lastBuildTime = Date.now()
448+
lw.compile.lastAutoBuildTime = Date.now()
449449
await vscode.window.activeTextEditor?.document.save()
450450
}
451451

test/suites/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export async function reset() {
7676
await vscode.commands.executeCommand('workbench.action.closeAllEditors')
7777
await Promise.all(Object.values(lw.cache.promises))
7878
lw.compile.lastSteps = []
79-
lw.compile.lastBuildTime = 0
79+
lw.compile.lastAutoBuildTime = 0
8080
lw.compile.compiledPDFPath = ''
8181
lw.compile.compiledPDFWriting = 0
8282
lw.root.file.path = undefined

0 commit comments

Comments
 (0)