From db813d516cda56a7786f22912de50d9c3a6f08fd Mon Sep 17 00:00:00 2001 From: Liangliang Zhu Date: Mon, 2 Dec 2024 10:32:41 +0800 Subject: [PATCH] fix #4474 --- src/lint/latex-formatter/tex-fmt.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lint/latex-formatter/tex-fmt.ts b/src/lint/latex-formatter/tex-fmt.ts index e146b5d22..19ed042f6 100644 --- a/src/lint/latex-formatter/tex-fmt.ts +++ b/src/lint/latex-formatter/tex-fmt.ts @@ -43,9 +43,13 @@ async function formatDocument(document: vscode.TextDocument, range?: vscode.Rang }) }) - process.stdin?.write(document.getText(range)) + // write the document to the process, and add a newline at the end + process.stdin?.write(document.getText(range)+'\n') process.stdin?.end() const edits = await promise - + // remove extra newline at the end + if (edits) { + edits.newText = edits.newText.replace(/\n$/, '') + } return edits }