Skip to content

Commit

Permalink
Code format of #4475
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Dec 7, 2024
1 parent 6b37c0d commit 60d8b38
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lint/latex-formatter/tex-fmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ async function formatDocument(document: vscode.TextDocument, range?: vscode.Rang
resolve(vscode.TextEdit.replace(range ?? document.validateRange(new vscode.Range(0, 0, Number.MAX_VALUE, Number.MAX_VALUE)), stdoutStr))
})
})

// 2024-12-4, for tex-fmt 0.4.7, when using `--stdin`, it requires a newline at the end of the input; Therefore, we need to add a newline at the end of the input if it doesn't exist, and remove it from the output if it exists.
const text = document.getText(range);
const endsWithNewline = text.endsWith('\n');
process.stdin?.write(endsWithNewline ? text : text + '\n');
process.stdin?.end();
const edits = await promise;
const text = document.getText(range)
const endsWithNewline = text.endsWith('\n')
process.stdin?.write(endsWithNewline ? text : text + '\n')
process.stdin?.end()
const edits = await promise
if (edits) {
edits.newText = endsWithNewline ? edits.newText : edits.newText.replace(/\n$/, '');
edits.newText = endsWithNewline ? edits.newText : edits.newText.replace(/\n$/, '')
}
return edits
}

0 comments on commit 60d8b38

Please sign in to comment.