Skip to content

Commit

Permalink
Ditto
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Dec 12, 2023
1 parent 41386a8 commit 9cb88f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 3 additions & 7 deletions src/lint/latex-linter/chktex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { convertFilenameEncoding } from '../../utils/convertfilename'

const logger = lw.log('Linter', 'ChkTeX')

const getName = () => 'ChkTeX'
export const chkTeX: LaTeXLinter = {
linterDiagnostics: vscode.languages.createDiagnosticCollection(getName()),
getName,
Expand All @@ -18,13 +19,8 @@ export const chkTeX: LaTeXLinter = {
parseLog
}

const linterName = 'ChkTeX'
let linterProcess: ChildProcessWithoutNullStreams | undefined

function getName() {
return linterName
}

async function lintRootFile(rootPath: string) {
const requiredArgs = ['-f%f:%l:%c:%d:%k:%n:%m\n', rootPath]

Expand Down Expand Up @@ -65,7 +61,7 @@ async function chktexWrapper(linterid: string, configScope: vscode.Configuration
let stdout: string
try {
linterProcess?.kill()
logger.logCommand(`Linter for ${linterName} command`, command, args.concat(requiredArgs).filter(arg => arg !== ''))
logger.logCommand(`Linter for ${getName()} command`, command, args.concat(requiredArgs).filter(arg => arg !== ''))
linterProcess = spawn(command, args.concat(requiredArgs).filter(arg => arg !== ''), { cwd: path.dirname(filePath) })
stdout = await processWrapper(linterid, linterProcess, content)
} catch (err: any) {
Expand Down Expand Up @@ -264,7 +260,7 @@ function showLinterDiagnostics(linterLog: ChkTeXLogEntry[]) {
)
const diag = new vscode.Diagnostic(range, item.text, DIAGNOSTIC_SEVERITY[item.type])
diag.code = item.code
diag.source = linterName
diag.source = getName()
if (diagsCollection[item.file] === undefined) {
diagsCollection[item.file] = []
}
Expand Down
10 changes: 3 additions & 7 deletions src/lint/latex-linter/lacheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { convertFilenameEncoding } from '../../utils/convertfilename'

const logger = lw.log('Linter', 'LaCheck')

const getName = () => 'LaCheck'
export const laCheck: LaTeXLinter = {
linterDiagnostics: vscode.languages.createDiagnosticCollection(getName()),
getName,
Expand All @@ -17,13 +18,8 @@ export const laCheck: LaTeXLinter = {
parseLog
}

const linterName = 'LaCheck'
let linterProcess: ChildProcessWithoutNullStreams | undefined

function getName() {
return linterName
}

async function lintRootFile(rootPath: string) {
const stdout = await lacheckWrapper('root', vscode.Uri.file(rootPath), rootPath, undefined)
if (stdout === undefined) { // It's possible to have empty string as output
Expand Down Expand Up @@ -52,7 +48,7 @@ async function lacheckWrapper(linterid: string, configScope: vscode.Configuratio
let stdout: string
try {
linterProcess?.kill()
logger.logCommand(`Linter for ${linterName} command`, command, [ filePath ])
logger.logCommand(`Linter for ${getName()} command`, command, [ filePath ])
linterProcess = spawn(command, [ filePath ], { cwd: path.dirname(filePath) })
stdout = await processWrapper(linterid, linterProcess, content)
} catch (err: any) {
Expand Down Expand Up @@ -115,7 +111,7 @@ function showLinterDiagnostics(linterLog: LaCheckLogEntry[]) {
new vscode.Position(item.line - 1, 65535)
)
const diag = new vscode.Diagnostic(range, item.text, vscode.DiagnosticSeverity.Warning)
diag.source = linterName
diag.source = getName()
if (diagsCollection[item.file] === undefined) {
diagsCollection[item.file] = []
}
Expand Down

0 comments on commit 9cb88f6

Please sign in to comment.