Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4347 max-print-line should be added to string when magic tex arg is present #4385

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/compile/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,23 @@ function populateTools(rootFile: string, buildTools: Tool[]): Tool[] {
})
if (configuration.get('latex.option.maxPrintLine.enabled')) {
tool.args = tool.args ?? []
const isLuaLatex = tool.args.includes('-lualatex') ||
tool.args.includes('-pdflua') ||
tool.args.includes('-pdflualatex') ||
tool.args.includes('--lualatex') ||
tool.args.includes('--pdflua') ||
tool.args.includes('--pdflualatex')
if (((tool.command === 'latexmk' && !isLuaLatex) || tool.command === 'pdflatex') && isMikTeX()) {
tool.args.unshift('--max-print-line=' + lw.constant.MAX_PRINT_LINE)
const isLaTeXmk =
tool.command === 'latexmk' &&
!(
tool.args.includes('-lualatex') ||
tool.args.includes('-pdflua') ||
tool.args.includes('-pdflualatex') ||
tool.args.includes('--lualatex') ||
tool.args.includes('--pdflua') ||
tool.args.includes('--pdflualatex')
)
if ((isLaTeXmk || tool.command === 'pdflatex') && isMikTeX()) {
if (tool.name === lw.constant.TEX_MAGIC_PROGRAM_NAME) {
// %!TeX options is present. All args are provided in a string and { shell: true }
tool.args = [ `--max-print-line=${lw.constant.MAX_PRINT_LINE} ${tool.args.join(' ')}` ]
} else {
tool.args.unshift('--max-print-line=' + lw.constant.MAX_PRINT_LINE)
}
}
}
})
Expand Down
16 changes: 16 additions & 0 deletions test/units/06_compile_recipe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,22 @@ describe(path.basename(__filename).split('.')[0] + ':', () => {
assert.ok(step)
assert.ok(!step.args?.includes('--max-print-line=' + lw.constant.MAX_PRINT_LINE), step.args?.join(' '))
})

it('should add --max-print-line argument to the arg string with MikTeX and %!TeX options', async () => {
await set.config('latex.option.maxPrintLine.enabled', true)
await set.config('latex.tools', [{ name: 'latexmk', command: 'latexmk' }])
await set.config('latex.build.forceRecipeUsage', false)
syncStub.returns({ stdout: 'pdfTeX 3.14159265-2.6-1.40.21 (MiKTeX 2.9.7350 64-bit)' })
readStub.resolves('% !TEX program = latexmk\n% !TEX options = -synctex=1 -interaction=nonstopmode -file-line-error\n')
const rootFile = set.root('main.tex')
initialize()

await build(rootFile, 'latex', async () => {})

const step = queue.getStep()
assert.ok(step)
assert.strictEqual(step.args?.[0], '--max-print-line=10000 -synctex=1 -interaction=nonstopmode -file-line-error', JSON.stringify(step.args))
})
})

describe('lw.compile->recipe.isMikTeX', () => {
Expand Down
Loading