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
ba1633ff
Commit
ba1633ff
authored
5 months ago
by
panoanx
Browse files
Options
Downloads
Patches
Plain Diff
fix: stringify chunk before merging chunks breaks character at the end
parent
f9409433
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/latexindent.ts
+11
-7
11 additions, 7 deletions
src/lint/latex-formatter/latexindent.ts
with
11 additions
and
7 deletions
src/lint/latex-formatter/latexindent.ts
+
11
−
7
View file @
ba1633ff
...
...
@@ -156,15 +156,19 @@ function format(document: vscode.TextDocument, range?: vscode.Range): Thenable<v
logger
.
logCommand
(
'
Formatting LaTeX.
'
,
formatter
,
args
)
const
worker
=
cs
.
spawn
(
formatter
,
args
,
{
stdio
:
'
pipe
'
,
cwd
:
documentDirectory
})
// handle stdout/stderr
const
stdoutBuffer
:
string
[]
=
[]
const
stderrBuffer
:
string
[]
=
[]
worker
.
stdout
.
on
(
'
data
'
,
(
chunk
:
Buffer
|
string
)
=>
stdoutBuffer
.
push
(
chunk
.
toString
()))
worker
.
stderr
.
on
(
'
data
'
,
(
chunk
:
Buffer
|
string
)
=>
stderrBuffer
.
push
(
chunk
.
toString
()))
const
stdoutBuffer
:
Buffer
[]
=
[]
const
stderrBuffer
:
Buffer
[]
=
[]
worker
.
stdout
.
on
(
'
data
'
,
(
chunk
:
Buffer
|
string
)
=>
{
stdoutBuffer
.
push
(
Buffer
.
isBuffer
(
chunk
)
?
chunk
:
Buffer
.
from
(
chunk
))
})
worker
.
stderr
.
on
(
'
data
'
,
(
chunk
:
Buffer
|
string
)
=>
{
stderrBuffer
.
push
(
Buffer
.
isBuffer
(
chunk
)
?
chunk
:
Buffer
.
from
(
chunk
))
})
worker
.
on
(
'
error
'
,
err
=>
{
removeTemporaryFiles
()
void
logger
.
showErrorMessage
(
'
Formatting failed. Please refer to LaTeX Workshop Output for details.
'
)
logger
.
log
(
`Formatting failed:
${
err
.
message
}
`
)
logger
.
log
(
`stderr:
${
stderrBuffer
.
join
(
''
)}
`
)
logger
.
log
(
`stderr:
${
Buffer
.
concat
(
stderrBuffer
).
toString
(
)}
`
)
resolve
(
undefined
)
})
worker
.
on
(
'
close
'
,
code
=>
{
...
...
@@ -172,10 +176,10 @@ function format(document: vscode.TextDocument, range?: vscode.Range): Thenable<v
if
(
code
!==
0
)
{
void
logger
.
showErrorMessage
(
'
Formatting failed. Please refer to LaTeX Workshop Output for details.
'
)
logger
.
log
(
`Formatting failed with exit code
${
code
}
`
)
logger
.
log
(
`stderr:
${
stderrBuffer
.
join
(
''
)}
`
)
logger
.
log
(
`stderr:
${
Buffer
.
concat
(
stderrBuffer
).
toString
(
)}
`
)
return
resolve
(
undefined
)
}
const
stdout
=
stdoutBuffer
.
join
(
''
)
const
stdout
=
Buffer
.
concat
(
stdoutBuffer
).
toString
(
)
if
(
stdout
!==
''
)
{
const
edit
=
vscode
.
TextEdit
.
replace
(
range
??
document
.
validateRange
(
new
vscode
.
Range
(
0
,
0
,
Number
.
MAX_VALUE
,
Number
.
MAX_VALUE
)),
stdout
)
logger
.
log
(
'
Formatted
'
+
document
.
fileName
)
...
...
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