From a8818da4c5af05880a126204daa925e2b2548ebb Mon Sep 17 00:00:00 2001 From: James Yu Date: Tue, 21 Nov 2023 12:23:51 +0000 Subject: [PATCH] Enable the mis-disabled eslint --- .eslintignore | 1 - src/compile/build.ts | 68 ++++++++++---------- src/compile/external.ts | 2 +- src/compile/queue.ts | 2 +- src/compile/recipe.ts | 2 +- src/compile/terminate.ts | 2 +- src/core/cache.ts | 100 +++++++++++++++--------------- src/core/file.ts | 4 +- src/core/root.ts | 2 +- src/lw.ts | 4 +- src/outline/structurelib/types.ts | 2 +- src/types.ts | 32 +++++----- src/utils/quick-pick.ts | 16 ++--- 13 files changed, 118 insertions(+), 119 deletions(-) diff --git a/.eslintignore b/.eslintignore index f0bf621b6..374b7661c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,4 @@ dev/*.js -src/**/*.* types/**/*.ts resources/**/*.js out diff --git a/src/compile/build.ts b/src/compile/build.ts index a445498f2..9688026d6 100644 --- a/src/compile/build.ts +++ b/src/compile/build.ts @@ -2,7 +2,7 @@ import * as vscode from 'vscode' import * as path from 'path' import * as cs from 'cross-spawn' import { AutoBuildInitiated, AutoCleaned, BuildDone } from '../core/event-bus' -import { rootFile as pickRootFile } from '../utils/quick-pick' +import { pickRootPath } from '../utils/quick-pick' import { parser } from '../parse/parser' import { lw } from '../lw' @@ -32,7 +32,7 @@ lw.watcher.bib.onChange(filePath => autoBuild(filePath, 'onFileChange', true)) * @param {boolean} bibChanged - Indicates whether the bibliography file has * changed. */ -function autoBuild(file: string, type: 'onFileChange' | 'onSave', bibChanged: boolean = false) { +function autoBuild(file: string, type: 'onFileChange' | 'onSave', bibChanged: boolean = false) { const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(file)) if (configuration.get('latex.autoBuild.run') as string !== type) { return @@ -84,10 +84,10 @@ function canAutoBuild(): boolean { * build. */ async function build(skipSelection: boolean = false, rootFile: string | undefined = undefined, languageId: string | undefined = undefined, recipe: string | undefined = undefined) { - const activeEditor = vscode.window.activeTextEditor; + const activeEditor = vscode.window.activeTextEditor if (!activeEditor) { logger.log('Cannot start to build because the active editor is undefined.') - return; + return } logger.log(`The document of the active editor: ${activeEditor.document.uri.toString(true)}`) @@ -115,7 +115,7 @@ async function build(skipSelection: boolean = false, rootFile: string | undefine let pickedRootFile: string | undefined = rootFile if (!skipSelection && lw.root.subfiles.path) { // We are using the subfile package - pickedRootFile = await pickRootFile(rootFile, lw.root.subfiles.path, 'build') + pickedRootFile = await pickRootPath(rootFile, lw.root.subfiles.path, 'compile') if (! pickedRootFile) { return } @@ -192,7 +192,7 @@ function spawnProcess(step: Step): ProcessEnv { logger.log(`env: ${JSON.stringify(step.env)}`) logger.log(`root: ${step.rootFile}`) - const env = { ...process.env, ...step.env } as ProcessEnv + const env: ProcessEnv = { ...process.env, ...step.env } env['max_print_line'] = lw.constant.MAX_PRINT_LINE if (!step.isExternal && @@ -261,7 +261,7 @@ async function monitorProcess(step: Step, env: ProcessEnv): Promise { resolve(false) }) - lw.compile.process.on('exit', async (code, signal) => { + lw.compile.process.on('exit', (code, signal) => { const isSkipped = parser.parseLog(stdout, step.rootFile) if (!step.isExternal) { step.isSkipped = isSkipped @@ -322,23 +322,23 @@ function handleProcessError(env: ProcessEnv, stderr: string, err: Error) { */ function handleExitCodeError(step: Step, env: ProcessEnv, stderr: string, code: number | null, signal: NodeJS.Signals | null) { if (!step.isExternal) { - logger.log(`Recipe returns with error code ${code}/${signal} on PID ${lw.compile.process?.pid}.`); - logger.log(`Does the executable exist? $PATH: ${env['PATH']}, $Path: ${env['Path']}, $SHELL: ${process.env.SHELL}`); - logger.log(`${stderr}`); + logger.log(`Recipe returns with error code ${code}/${signal} on PID ${lw.compile.process?.pid}.`) + logger.log(`Does the executable exist? $PATH: ${env['PATH']}, $Path: ${env['Path']}, $SHELL: ${process.env.SHELL}`) + logger.log(`${stderr}`) } - const configuration = vscode.workspace.getConfiguration('latex-workshop', step.rootFile ? vscode.Uri.file(step.rootFile) : undefined); + const configuration = vscode.workspace.getConfiguration('latex-workshop', step.rootFile ? vscode.Uri.file(step.rootFile) : undefined) if (!step.isExternal && signal !== 'SIGTERM' && !step.isRetry && configuration.get('latex.autoBuild.cleanAndRetry.enabled')) { - handleRetryError(step); + handleRetryError(step) } else if (!step.isExternal && signal !== 'SIGTERM') { - handleNoRetryError(configuration, step); + handleNoRetryError(configuration, step) } else if (step.isExternal) { - handleExternalCommandError(); + handleExternalCommandError() } else { - handleUserTermination(); + handleUserTermination() } - lw.compile.process = undefined; + lw.compile.process = undefined } /** @@ -348,13 +348,12 @@ function handleExitCodeError(step: Step, env: ProcessEnv, stderr: string, code: * @param {RecipeStep} step - The Step representing the tool process. */ function handleRetryError(step: RecipeStep) { - step.isRetry = true; - logger.refreshStatus('x', 'errorForeground', 'Recipe terminated with error. Retry building the project.', 'warning'); - logger.log('Cleaning auxiliary files and retrying build after toolchain error.'); + step.isRetry = true + logger.refreshStatus('x', 'errorForeground', 'Recipe terminated with error. Retry building the project.', 'warning') + logger.log('Cleaning auxiliary files and retrying build after toolchain error.') - queue.prepend(step); - lw.cleaner.clean(step.rootFile); - lw.eventBus.fire(AutoCleaned); + queue.prepend(step) + void lw.cleaner.clean(step.rootFile).then(() => lw.eventBus.fire(AutoCleaned)) } /** @@ -366,14 +365,13 @@ function handleRetryError(step: RecipeStep) { * the LaTeX project. * @param {RecipeStep} step - The Step representing the tool process. */ -async function handleNoRetryError(configuration: vscode.WorkspaceConfiguration, step: RecipeStep) { - logger.refreshStatus('x', 'errorForeground'); +function handleNoRetryError(configuration: vscode.WorkspaceConfiguration, step: RecipeStep) { + logger.refreshStatus('x', 'errorForeground') if (['onFailed', 'onBuilt'].includes(configuration.get('latex.autoClean.run') as string)) { - lw.cleaner.clean(step.rootFile); - lw.eventBus.fire(AutoCleaned); + void lw.cleaner.clean(step.rootFile).then(() => lw.eventBus.fire(AutoCleaned)) } - void logger.showErrorMessageWithCompilerLogButton('Recipe terminated with error.'); - queue.clear(); + void logger.showErrorMessageWithCompilerLogButton('Recipe terminated with error.') + queue.clear() } /** @@ -381,10 +379,10 @@ async function handleNoRetryError(configuration: vscode.WorkspaceConfiguration, * shows an error message to the user and clears the BuildToolQueue. */ function handleExternalCommandError() { - logger.log(`Build returns with error on PID ${lw.compile.process?.pid}.`); - logger.refreshStatus('x', 'errorForeground', undefined, 'warning'); - void logger.showErrorMessageWithCompilerLogButton('Build terminated with error.'); - queue.clear(); + logger.log(`Build returns with error on PID ${lw.compile.process?.pid}.`) + logger.refreshStatus('x', 'errorForeground', undefined, 'warning') + void logger.showErrorMessageWithCompilerLogButton('Build terminated with error.') + queue.clear() } /** @@ -392,8 +390,8 @@ function handleExternalCommandError() { * the status and clears the BuildToolQueue. */ function handleUserTermination() { - logger.refreshStatus('x', 'errorForeground'); - queue.clear(); + logger.refreshStatus('x', 'errorForeground') + queue.clear() } /** @@ -419,7 +417,7 @@ async function afterSuccessfulBuilt(lastStep: Step, skipped: boolean) { } lw.viewer.refreshExistingViewer(lw.file.getPdfPath(lastStep.rootFile)) lw.completer.reference.setNumbersFromAuxFile(lastStep.rootFile) - lw.cache.loadFlsFile(lastStep.rootFile ?? '') + await lw.cache.loadFlsFile(lastStep.rootFile ?? '') const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(lastStep.rootFile)) // If the PDF viewer is internal, we call SyncTeX in src/components/viewer.ts. if (configuration.get('view.pdf.viewer') === 'external' && configuration.get('synctex.afterBuild.enabled')) { diff --git a/src/compile/external.ts b/src/compile/external.ts index 9bca67f3d..4e43128e6 100644 --- a/src/compile/external.ts +++ b/src/compile/external.ts @@ -38,4 +38,4 @@ export async function build(command: string, args: string[], pwd: string, buildL queue.add(tool, rootFile, 'External', Date.now(), true, cwd) await buildLoop() -} \ No newline at end of file +} diff --git a/src/compile/queue.ts b/src/compile/queue.ts index 57f2bd3a3..0d523069c 100644 --- a/src/compile/queue.ts +++ b/src/compile/queue.ts @@ -102,4 +102,4 @@ export const queue = { isLastStep, getStep, getStepString -} \ No newline at end of file +} diff --git a/src/compile/recipe.ts b/src/compile/recipe.ts index 07c168c17..3987c63d5 100644 --- a/src/compile/recipe.ts +++ b/src/compile/recipe.ts @@ -322,4 +322,4 @@ function isMikTeX(): boolean { } } return _isMikTeX -} \ No newline at end of file +} diff --git a/src/compile/terminate.ts b/src/compile/terminate.ts index 9053a6bee..c689f4a18 100644 --- a/src/compile/terminate.ts +++ b/src/compile/terminate.ts @@ -32,4 +32,4 @@ export function terminate() { lw.compile.process.kill() logger.log(`Killed the current process with PID ${pid}`) } -} \ No newline at end of file +} diff --git a/src/core/cache.ts b/src/core/cache.ts index 2b05d2f86..ef4dff311 100644 --- a/src/core/cache.ts +++ b/src/core/cache.ts @@ -116,10 +116,10 @@ function paths(): string[] { * * @param {string} filePath - The file path to wait for. * @param {number} seconds - The maximum wait time in seconds. - * @returns {Promise} - A promise resolving when the file is + * @returns {Promise | undefined>} - A promise resolving when the file is * cached, or undefined if an error occurs. */ -async function wait(filePath: string, seconds: number = 2): Promise { +async function wait(filePath: string, seconds: number = 2): Promise | undefined> { let waited = 0 while (promises.get(filePath) === undefined && get(filePath) === undefined) { // Just open vscode, has not cached, wait for a bit? @@ -164,10 +164,10 @@ let cachingFilesCount = 0 * * @param {string} filePath - The file path to refresh the cache for. * @param {string} rootPath - The root path for resolving relative paths. - * @returns {Promise} - A promise resolving when the cache is + * @returns {Promise | undefined>} - A promise resolving when the cache is * refreshed, or undefined if the file is excluded or cannot be cached. */ -async function refreshCache(filePath: string, rootPath?: string): Promise { +async function refreshCache(filePath: string, rootPath?: string): Promise | undefined> { if (isExcluded(filePath)) { logger.log(`Ignored ${filePath} .`) return @@ -180,7 +180,7 @@ async function refreshCache(filePath: string, rootPath?: string): Promise document.fileName === path.normalize(filePath)) const content = openEditor?.isDirty ? openEditor.getText() : (lw.file.read(filePath) ?? '') - const cache: FileCache = { + const fileCache: FileCache = { filePath, content, contentTrimmed: utils.stripCommentsAndVerbatim(content), @@ -188,14 +188,14 @@ async function refreshCache(filePath: string, rootPath?: string): Promise { - updateElements(cache) + updateAST(fileCache).then(() => { + updateElements(fileCache) }).finally(() => { lw.dupLabelDetector.run() cachingFilesCount-- @@ -242,26 +242,26 @@ function refreshCacheAggressive(filePath: string) { /** * Updates the Abstract Syntax Tree (AST) for a given file cache using parser. * - * @param {FileCache} cache - The file cache to update the AST for. + * @param {FileCache} fileCache - The file cache to update the AST for. */ -async function updateAST(cache: FileCache) { - logger.log(`Parse LaTeX AST: ${cache.filePath} .`) - cache.ast = await parser.parseLaTeX(cache.content) - logger.log(`Parsed LaTeX AST: ${cache.filePath} .`) +async function updateAST(fileCache: FileCache) { + logger.log(`Parse LaTeX AST: ${fileCache.filePath} .`) + fileCache.ast = await parser.parseLaTeX(fileCache.content) + logger.log(`Parsed LaTeX AST: ${fileCache.filePath} .`) } /** * Updates the children of a file cache based on input files and external * documents. * - * @param {FileCache} cache - The file cache to update the children for. + * @param {FileCache} fileCache - The file cache to update the children for. * @param {string} rootPath - The root path for resolving relative paths. */ -function updateChildren(cache: FileCache, rootPath: string | undefined) { - rootPath = rootPath || cache.filePath - updateChildrenInput(cache, rootPath) - updateChildrenXr(cache, rootPath) - logger.log(`Updated inputs of ${cache.filePath} .`) +function updateChildren(fileCache: FileCache, rootPath: string | undefined) { + rootPath = rootPath || fileCache.filePath + updateChildrenInput(fileCache, rootPath) + updateChildrenXr(fileCache, rootPath) + logger.log(`Updated inputs of ${fileCache.filePath} .`) } /** @@ -273,13 +273,13 @@ function updateChildren(cache: FileCache, rootPath: string | undefined) { * the children array, and if the file is not already being watched, it adds it * to the watcher and triggers a refresh of its cache. * - * @param {FileCache} cache - The file cache to update the input children for. + * @param {FileCache} fileCache - The file cache to update the input children for. * @param {string} rootPath - The root path for resolving relative paths. */ -function updateChildrenInput(cache: FileCache, rootPath: string) { +function updateChildrenInput(fileCache: FileCache, rootPath: string) { const inputFileRegExp = new InputFileRegExp() while (true) { - const result = inputFileRegExp.exec(cache.contentTrimmed, cache.filePath, rootPath) + const result = inputFileRegExp.exec(fileCache.contentTrimmed, fileCache.filePath, rootPath) if (!result) { break } @@ -288,11 +288,11 @@ function updateChildrenInput(cache: FileCache, rootPath: string) { continue } - cache.children.push({ + fileCache.children.push({ index: result.match.index, filePath: result.path }) - logger.log(`Input ${result.path} from ${cache.filePath} .`) + logger.log(`Input ${result.path} from ${fileCache.filePath} .`) if (lw.watcher.src.has(result.path)) { continue @@ -312,20 +312,20 @@ function updateChildrenInput(cache: FileCache, rootPath: string) { * document is not already being watched, it adds it to the watcher and triggers * a refresh of its cache. * - * @param {FileCache} cache - The file cache to update the external document + * @param {FileCache} fileCache - The file cache to update the external document * children for. * @param {string} rootPath - The root path for resolving relative paths. */ -function updateChildrenXr(cache: FileCache, rootPath: string) { +function updateChildrenXr(fileCache: FileCache, rootPath: string) { const externalDocRegExp = /\\externaldocument(?:\[(.*?)\])?\{(.*?)\}/g while (true) { - const result = externalDocRegExp.exec(cache.contentTrimmed) + const result = externalDocRegExp.exec(fileCache.contentTrimmed) if (!result) { break } const texDirs = vscode.workspace.getConfiguration('latex-workshop').get('latex.texDirs') as string[] - const externalPath = utils.resolveFile([path.dirname(cache.filePath), path.dirname(rootPath), ...texDirs], result[2]) + const externalPath = utils.resolveFile([path.dirname(fileCache.filePath), path.dirname(rootPath), ...texDirs], result[2]) if (!externalPath || !fs.existsSync(externalPath) || path.relative(externalPath, rootPath) === '') { logger.log(`Failed resolving external ${result[2]} . Tried ${externalPath} ` + (externalPath && path.relative(externalPath, rootPath) === '' ? ', which is root.' : '.')) @@ -335,7 +335,7 @@ function updateChildrenXr(cache: FileCache, rootPath: string) { const rootCache = get(rootPath) if (rootCache !== undefined) { rootCache.external[externalPath] = result[1] || '' - logger.log(`External document ${externalPath} from ${cache.filePath} .` + (result[1] ? ` Prefix is ${result[1]}`: '')) + logger.log(`External document ${externalPath} from ${fileCache.filePath} .` + (result[1] ? ` Prefix is ${result[1]}`: '')) } if (lw.watcher.src.has(externalPath)) { @@ -356,21 +356,21 @@ function updateChildrenXr(cache: FileCache, rootPath: string) { * the bibliography files referenced in the file content and logs the time taken * to complete the update. * - * @param {FileCache} cache - The file cache to update the elements for. + * @param {FileCache} fileCache - The file cache to update the elements for. */ -function updateElements(cache: FileCache) { +function updateElements(fileCache: FileCache) { const start = performance.now() - lw.completer.citation.parse(cache) + lw.completer.citation.parse(fileCache) // Package parsing must be before command and environment. - lw.completer.package.parse(cache) - lw.completer.reference.parse(cache) - lw.completer.glossary.parse(cache) - lw.completer.environment.parse(cache) - lw.completer.command.parse(cache) - lw.completer.input.parseGraphicsPath(cache) - updateBibfiles(cache) + lw.completer.package.parse(fileCache) + lw.completer.reference.parse(fileCache) + lw.completer.glossary.parse(fileCache) + lw.completer.environment.parse(fileCache) + lw.completer.command.parse(fileCache) + lw.completer.input.parseGraphicsPath(fileCache) + updateBibfiles(fileCache) const elapsed = performance.now() - start - logger.log(`Updated elements in ${elapsed.toFixed(2)} ms: ${cache.filePath} .`) + logger.log(`Updated elements in ${elapsed.toFixed(2)} ms: ${fileCache.filePath} .`) } /** @@ -383,13 +383,13 @@ function updateElements(cache: FileCache) { * If a bibliography file is not already being watched, it adds it to the * bibliography watcher. * - * @param {FileCache} cache - The file cache to update the bibliography files + * @param {FileCache} fileCache - The file cache to update the bibliography files * for. */ -function updateBibfiles(cache: FileCache) { +function updateBibfiles(fileCache: FileCache) { const bibReg = /(?:\\(?:bibliography|addbibresource)(?:\[[^[\]{}]*\])?){([\s\S]+?)}|(?:\\putbib)\[(.+?)\]/gm while (true) { - const result = bibReg.exec(cache.contentTrimmed) + const result = bibReg.exec(fileCache.contentTrimmed) if (!result) { break } @@ -397,10 +397,10 @@ function updateBibfiles(cache: FileCache) { const bibs = (result[1] ? result[1] : result[2]).split(',').map(bib => bib.trim()) for (const bib of bibs) { - const bibPaths = lw.file.getBibPath(bib, path.dirname(cache.filePath)) + const bibPaths = lw.file.getBibPath(bib, path.dirname(fileCache.filePath)) for (const bibPath of bibPaths) { - cache.bibfiles.add(bibPath) - logger.log(`Bib ${bibPath} from ${cache.filePath} .`) + fileCache.bibfiles.add(bibPath) + logger.log(`Bib ${bibPath} from ${fileCache.filePath} .`) if (!lw.watcher.bib.has(bibPath)) { lw.watcher.bib.add(bibPath) } @@ -450,10 +450,10 @@ async function loadFlsFile(filePath: string) { await refreshCache(filePath) } // It might be possible that `filePath` is excluded from caching. - const cache = get(filePath) - if (cache !== undefined) { + const fileCache = get(filePath) + if (fileCache !== undefined) { // Parse tex files as imported subfiles. - cache.children.push({ + fileCache.children.push({ index: Number.MAX_VALUE, filePath: inputFile }) diff --git a/src/core/file.ts b/src/core/file.ts index edd37a968..885222835 100644 --- a/src/core/file.ts +++ b/src/core/file.ts @@ -52,8 +52,8 @@ function createTmpDir(): string { function handleTmpDirError(error: Error) { if (/['"]/.exec(os.tmpdir())) { const msg = `The path of tmpdir cannot include single quotes and double quotes: ${os.tmpdir()}` - void vscode.window.showErrorMessage(msg); - console.log(msg); + void vscode.window.showErrorMessage(msg) + console.log(msg) } else { void vscode.window.showErrorMessage(`Error during making tmpdir to build TeX files: ${error.message}. Please check the environment variables, TEMP, TMP, and TMPDIR on your system.`) console.log(`TEMP, TMP, and TMPDIR: ${JSON.stringify([process.env.TEMP, process.env.TMP, process.env.TMPDIR])}`) diff --git a/src/core/root.ts b/src/core/root.ts index eafeeae9e..46d006f1b 100644 --- a/src/core/root.ts +++ b/src/core/root.ts @@ -75,7 +75,7 @@ async function find(): Promise { lw.eventBus.fire(eventbus.RootFileSearched) return } - logger.log(`No root file found.`) + logger.log('No root file found.') void lw.structureViewer.refresh() lw.eventBus.fire(eventbus.RootFileSearched) return diff --git a/src/lw.ts b/src/lw.ts index 45a735df2..dbe82dae8 100644 --- a/src/lw.ts +++ b/src/lw.ts @@ -30,6 +30,7 @@ import type { StructureView } from './outline/project' import type { TeXDoc } from './extras/texdoc' import type * as commands from './core/commands' +/* eslint-disable */ export const lw = { extensionContext: Object.create(null) as vscode.ExtensionContext, extensionRoot: '', @@ -65,6 +66,7 @@ export const lw = { mathPreviewPanel: Object.create(null) as MathPreviewPanel, commands: Object.create(null) as typeof commands } +/* eslint-enable */ const constant = { TEX_EXT: ['.tex', '.bib'], @@ -88,4 +90,4 @@ export function registerDisposable(...items: vscode.Disposable[]) { } else { disposables = [...disposables, ...items] } -} \ No newline at end of file +} diff --git a/src/outline/structurelib/types.ts b/src/outline/structurelib/types.ts index 9f0183ee6..30db92d02 100644 --- a/src/outline/structurelib/types.ts +++ b/src/outline/structurelib/types.ts @@ -10,4 +10,4 @@ export type TeXElement = { children: TeXElement[], parent?: TeXElement, appendix?: boolean -} \ No newline at end of file +} diff --git a/src/types.ts b/src/types.ts index 62527459e..f23ad045c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -46,7 +46,7 @@ export type StepQueue = { /** * The {@link Step}s in the current recipe. */ - steps: Step[] + steps: Step[], /** * The {@link Step}s in the next recipe to be executed after the current * ones. @@ -59,33 +59,33 @@ export type ProcessEnv = { } export type Tool = { - name: string - command: string - args?: string[] + name: string, + command: string, + args?: string[], env?: ProcessEnv } export type Recipe = { - name: string + name: string, tools: (string | Tool)[] } export type RecipeStep = Tool & { - rootFile: string - recipeName: string - timestamp: number - index: number - isExternal: false - isRetry: boolean + rootFile: string, + recipeName: string, + timestamp: number, + index: number, + isExternal: false, + isRetry: boolean, isSkipped: boolean } export type ExternalStep = Tool & { - rootFile?: string - recipeName: 'External' - timestamp: number - index: number - isExternal: true + rootFile?: string, + recipeName: 'External', + timestamp: number, + index: number, + isExternal: true, cwd: string } diff --git a/src/utils/quick-pick.ts b/src/utils/quick-pick.ts index a00de3e74..fe315c820 100644 --- a/src/utils/quick-pick.ts +++ b/src/utils/quick-pick.ts @@ -1,21 +1,21 @@ import * as vscode from 'vscode' -export async function rootFile(rootFile: string, localRootFile: string, verb: string): Promise { - const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(rootFile)) +export async function pickRootPath(rootPath: string, subRootPath: string, verb: string): Promise { + const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(rootPath)) const doNotPrompt = configuration.get('latex.rootFile.doNotPrompt') as boolean if (doNotPrompt) { if (configuration.get('latex.rootFile.useSubFile')) { - return localRootFile + return subRootPath } else { - return rootFile + return rootPath } } const pickedRootFile = await vscode.window.showQuickPick([{ label: 'Default root file', - description: `Path: ${rootFile}` + description: `Path: ${rootPath}` }, { label: 'Subfiles package root file', - description: `Path: ${localRootFile}` + description: `Path: ${subRootPath}` }], { placeHolder: `Subfiles package detected. Which file to ${verb}?`, matchOnDescription: true @@ -25,9 +25,9 @@ export async function rootFile(rootFile: string, localRootFile: string, verb: st } switch (selected.label) { case 'Default root file': - return rootFile + return rootPath case 'Subfiles package root file': - return localRootFile + return subRootPath default: return }