Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LaTeX-Workshop
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James-Yu
LaTeX-Workshop
Commits
4ea5f55d
Commit
4ea5f55d
authored
5 months ago
by
panoanx
Browse files
Options
Downloads
Patches
Plain Diff
fix: stdout concatenation for tex-fmt #4433
parent
ba1633ff
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lint/latex-formatter/tex-fmt.ts
+6
-5
6 additions, 5 deletions
src/lint/latex-formatter/tex-fmt.ts
with
6 additions
and
5 deletions
src/lint/latex-formatter/tex-fmt.ts
+
6
−
5
View file @
4ea5f55d
...
...
@@ -15,9 +15,9 @@ async function formatDocument(document: vscode.TextDocument, range?: vscode.Rang
const
args
=
[...(
config
.
get
(
'
formatting.tex-fmt.args
'
)
as
string
[]),
'
--stdin
'
]
const
process
=
lw
.
external
.
spawn
(
program
,
args
,
{
cwd
:
path
.
dirname
(
document
.
uri
.
fsPath
)
})
let
stdout
:
string
=
''
let
stdout
:
Buffer
=
Buffer
.
alloc
(
0
)
process
.
stdout
?.
on
(
'
data
'
,
(
msg
:
Buffer
|
string
)
=>
{
stdout
+
=
msg
stdout
=
Buffer
.
concat
([
stdout
,
Buffer
.
isBuffer
(
msg
)
?
msg
:
Buffer
.
from
(
msg
)])
})
const
promise
=
new
Promise
<
vscode
.
TextEdit
|
undefined
>
(
resolve
=>
{
...
...
@@ -33,12 +33,13 @@ async function formatDocument(document: vscode.TextDocument, range?: vscode.Rang
logger
.
showErrorMessage
(
`
${
program
}
returned
${
code
}
. Be cautious on the edits.`
)
resolve
(
undefined
)
}
let
stdoutStr
=
stdout
.
toString
()
// tex-fmt adds an extra newline at the end
if
(
stdout
.
endsWith
(
'
\n\n
'
))
{
stdout
=
stdout
.
slice
(
0
,
-
1
)
if
(
stdout
Str
.
endsWith
(
'
\n\n
'
))
{
stdout
Str
=
stdout
Str
.
slice
(
0
,
-
1
)
}
logger
.
log
(
`Formatted using
${
program
}
.`
)
resolve
(
vscode
.
TextEdit
.
replace
(
range
??
document
.
validateRange
(
new
vscode
.
Range
(
0
,
0
,
Number
.
MAX_VALUE
,
Number
.
MAX_VALUE
)),
stdout
))
resolve
(
vscode
.
TextEdit
.
replace
(
range
??
document
.
validateRange
(
new
vscode
.
Range
(
0
,
0
,
Number
.
MAX_VALUE
,
Number
.
MAX_VALUE
)),
stdout
Str
))
})
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment