Closed sleepymalc closed 1 year ago
I do confirm the issue.
@James-Yu I may miss something but I think there is something wrong with the logic of https://github.com/James-Yu/LaTeX-Workshop/blob/7848ea024737fc67146eb4670897d7d65b1c4b87/src/providers/latexformatter.ts#L58-L70
During the first call, LaTeXFormatter.formatter
is empty. Then, we enter the if
condition and LaTeXFormatter.checkPath()
fails because currentOs
is empty. Actually, initialize
seems to be never called. Yet, imagine latexindent
is indeed not available, we do not enter the if
condition during the second call because during the first one LaTeXFormatter.formatter = pathMeta
. So, we are going to call LaTeXFormatter.format
, whereas we should not as latexindent
is indeed not available.
Because the whole logic of LW has become quite elaborate, any change can unfortunately lead to unexpected bugs. Major refactoring or paradigm changes are virtually impossible to review to make sure nothing is broken or at least I could not. I am not sure what the best practice is and how to help.
That is the issue. The only way I can think of is to increase the test coverage, which is the thing I want to improve in the following period.
back to this issue, will fix very shortly.
During the first call,
LaTeXFormatter.formatter
is empty. Then, we enter theif
condition andLaTeXFormatter.checkPath()
fails becausecurrentOs
is empty. Actually,initialize
seems to be never called.
Yes, this is the root of bug: undefined currentOs
as initialize
was never called.
Yet, imagine
latexindent
is indeed not available, we do not enter theif
condition during the second call because during the first oneLaTeXFormatter.formatter = pathMeta
. So, we are going to callLaTeXFormatter.format
, whereas we should not aslatexindent
is indeed not available.
This is in fact an old uncovered issue. I've checked v9.1.0 and the logic was as so ever since. I suppose the new fix should work as now, if and only if formatter
is empty, the detection will kick in. If the detection eventually find something, formatter
is non-empty. If the detection is failed, formatter
is reset to empty.
Because the whole logic of LW has become quite elaborate, any change can unfortunately lead to unexpected bugs. Major refactoring or paradigm changes are virtually impossible to review to make sure nothing is broken or at least I could not. I am not sure what the best practice is and how to help.
I completely agree. I promise this will be the last huge paradigm change in the foreseeable future. I will dedicate to add tests on my inspections and public issues to increase the test coverage. You can count on me this time (trademark).
It takes a bit effort to make latexindent
work with Actions, yet finally we have 98e4c8e13fdd8b670475440c7abcea69d2ee292d to test formatter. Next are new tests, gradddduuuuaaaaly
The [Format]
logs look strange
[09:06:29][Format][TeX] Format with command The command is latexindent:["-c","%DIR%/","%TMPFILE%","-y=defaultIndent: '%INDENT%'","-l=/Users/jl/.latexindent.yaml"].
There is still something wrong with the way latex-workshop.latexindent.path
is handled. Any change in latex-workshop.latexindent.path
requires to reload vscode to be taken into account
Nice catch! Both fixed in 2508e74d
Preliminary questions
Disable all the other extensions except for LaTeX Workshop, restart VS Code, and check that you still see this issue.
You still see this issue?: Yes
Make sure to visit the wiki FAQ before filling an issue.
You visited the wiki?: Yes
If your issue is with compiling a document (not having to do with finding the root file of a project), check first that you can compile manually.
You can compile a TeX document manually?: Yes
Describe the bug [Required]
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
latexindent
Can not find latexindent in PATH.
latexindent
can be found and is formatting correctly.Expected behavior
Find the
latexindent
in the first try.Logs [Required]
Please paste the whole log messages here, not parts of ones. The log should start with
Initializing LaTeX Workshop
. It is very important to identify problems.LaTeX Workshop Output [Required]
p.s. the above is the log when compiling twice. The second time it correctly find
latexindent
.Developer Tools Console [Required]
Screenshots
If applicable, add screenshots to help explain your problem.
In addition, I didn't modify any setting for
latexindent
, i.e.,Desktop [Required]
Please write exact version numbers. Please don't write
latest
instead of exact numbers.Additional questions
Are you using VSCodium?
No
Are you using the Snap or Flatpack versions of VS Code?
No
Are you using LaTeX Workshop with VS Code Remote?
No
If the answer is Yes, please write which one you are using. Write the versions of the remote extension.
Additional context
None.