James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.66k stars 530 forks source link

latexindent can't find #3634

Closed sleepymalc closed 1 year ago

sleepymalc commented 1 year ago

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:

  1. Install latexindent
  2. Compile
  3. An error will show: Can not find latexindent in PATH.
  4. When compiling again, everything is back on track, i.e., 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]

To access the log, click the 'TeX' icon on the Activity Bar on the left side, select 'View Log Messages', then select 'View LaTeX Workshop extension log'.

[12:24:37][Logger] New log placeholder %WS1% registered for /Users/pbb/Developer/LaTeX-Template/Resume .
[12:24:37][Config] Configuration for workspace: file://%WS1% .
[12:24:37][Config] editor.acceptSuggestionOnEnter: "on" .
[12:24:37][Config] latex-workshop.bind.enter.key: true .
[12:24:37][Config] latex-workshop.docker.enabled: false .
[12:24:37][Config] latex-workshop.docker.image.latex: "" .
[12:24:37][Config] latex-workshop.hover.preview.mathjax.extensions: [] .
[12:24:37][Config] latex-workshop.intellisense.package.enabled: true .
[12:24:37][Config] latex-workshop.intellisense.update.aggressive.enabled: false .
[12:24:37][Config] latex-workshop.intellisense.update.delay: 1000 .
[12:24:37][Config] latex-workshop.latex.autoBuild.run: "onSave" .
[12:24:37][Config] latex-workshop.latex.build.forceRecipeUsage: true .
[12:24:37][Config] latex-workshop.latex.outDir: "%DIR%" .
[12:24:37][Config] latex-workshop.latex.recipes: [
 {
  "name": "latexmk",
  "tools": [
   "latexmk"
  ]
 },
 {
  "name": "latexmk (latexmkrc)",
  "tools": [
   "latexmk_rconly"
  ]
 },
 {
  "name": "latexmk (lualatex)",
  "tools": [
   "lualatexmk"
  ]
 },
 {
  "name": "latexmk (xelatex)",
  "tools": [
   "xelatexmk"
  ]
 },
 {
  "name": "pdflatex -> bibtex -> pdflatex * 2",
  "tools": [
   "pdflatex",
   "bibtex",
   "pdflatex",
   "pdflatex"
  ]
 },
 {
  "name": "Compile Rnw files",
  "tools": [
   "rnw2tex",
   "latexmk"
  ]
 },
 {
  "name": "Compile Jnw files",
  "tools": [
   "jnw2tex",
   "latexmk"
  ]
 },
 {
  "name": "Compile Pnw files",
  "tools": [
   "pnw2tex",
   "latexmk"
  ]
 },
 {
  "name": "tectonic",
  "tools": [
   "tectonic"
  ]
 }
] .
[12:24:37][Config] latex-workshop.latex.tools: [
 {
  "name": "latexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-pdf",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "lualatexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-lualatex",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "xelatexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-xelatex",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "latexmk_rconly",
  "command": "latexmk",
  "args": [
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "pdflatex",
  "command": "pdflatex",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "bibtex",
  "command": "bibtex",
  "args": [
   "%DOCFILE%"
  ],
  "env": {}
 },
 {
  "name": "rnw2tex",
  "command": "Rscript",
  "args": [
   "-e",
   "knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"
  ],
  "env": {}
 },
 {
  "name": "jnw2tex",
  "command": "julia",
  "args": [
   "-e",
   "using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")"
  ],
  "env": {}
 },
 {
  "name": "jnw2texminted",
  "command": "julia",
  "args": [
   "-e",
   "using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"
  ],
  "env": {}
 },
 {
  "name": "pnw2tex",
  "command": "pweave",
  "args": [
   "-f",
   "tex",
   "%DOC_EXT%"
  ],
  "env": {}
 },
 {
  "name": "pnw2texminted",
  "command": "pweave",
  "args": [
   "-f",
   "texminted",
   "%DOC_EXT%"
  ],
  "env": {}
 },
 {
  "name": "tectonic",
  "command": "tectonic",
  "args": [
   "--synctex",
   "--keep-logs",
   "%DOC%.tex"
  ],
  "env": {}
 }
] .
[12:24:37][Config] latex-workshop.viewer.pdf.internal.keyboardEvent: "auto" .
[12:24:37][Manager] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[12:24:37][Server] Creating LaTeX Workshop http and websocket server.
[12:24:37][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":51639}
[12:24:37][Server] valdOrigin is http://127.0.0.1:51639
[12:24:37][Extension] Initializing LaTeX Workshop.
[12:24:37][Extension] Extension root: /Users/pbb/.vscode/extensions/james-yu.latex-workshop-9.4.3
[12:24:37][Extension] $PATH: /Users/pbb/opt/anaconda3/bin:/Users/pbb/opt/anaconda3/condabin:/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/homebrew/bin:/Users/pbb/.fig/bin:/Users/pbb/.local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin:/Library/TeX/texbin
[12:24:37][Extension] $SHELL: /usr/local/bin/fish
[12:24:37][Extension] $LANG: undefined
[12:24:37][Extension] $LC_ALL: undefined
[12:24:37][Extension] process.platform: darwin
[12:24:37][Extension] process.arch: arm64
[12:24:37][Extension] vscode.env.appName: Visual Studio Code
[12:24:37][Extension] vscode.env.remoteName: undefined
[12:24:37][Extension] vscode.env.uiKind: 1
[12:24:37][Extension] LaTeX Workshop initialized.
[12:24:37][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[12:24:37][] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[12:24:37][Manager] Current workspace folders: ["file://%WS1%"]
[12:24:37][Manager] Current workspaceRootDir: file://%WS1%
[12:24:37][Viewer][Panel] Restoring at column 1 with state {"pdfFileUri":"file://%WS1%/resume.pdf","scale":"2.2","scrollMode":0,"spreadMode":0,"scrollTop":0,"scrollLeft":0,"trim":0,"synctexEnabled":true,"autoReloadEnabled":true}.
[12:24:37][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:51639/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRlVzZXJzJTJGcGJiJTJGRGV2ZWxvcGVyJTJGTGFUZVgtVGVtcGxhdGUlMkZSZXN1bWUlMkZyZXN1bWUucGRm .
[12:24:37][Cacher][PDF] Watched file://%WS1%/resume.pdf .
[12:24:37][Cacher][Path] Non-existent .fls for %WS1%/resume.tex .
[12:24:37][Cacher] Caching %WS1%/resume.tex .
[12:24:37][Cacher] Updated inputs of %WS1%/resume.tex .
[12:24:37][DupLabel] Checking for duplicate labels: %WS1%/resume.tex .
[12:24:37][Cacher] Updated elements of %WS1%/resume.tex .
[12:24:37][Cacher] Updated bibs of %WS1%/resume.tex .
[12:24:37][Cacher] Cached %WS1%/resume.tex .
[12:24:37][Manager] Found files that might be root, choose the first one: %WS1%/resume.tex
[12:24:37][Manager] Root file changed: from undefined to %WS1%/resume.tex
[12:24:37][Manager] Start to find all dependencies.
[12:24:37][Manager] Root file languageId: latex
[12:24:37][Cacher][Watcher] Reset.
[12:24:37][Cacher] Adding %WS1%/resume.tex .
[12:24:37][Cacher] Caching %WS1%/resume.tex .
[12:24:37][Cacher] Updated inputs of %WS1%/resume.tex .
[12:24:37][Cacher][Watcher] Watched %WS1%/resume.tex .
[12:24:37][DupLabel] Checking for duplicate labels: %WS1%/resume.tex .
[12:24:37][Cacher] Updated elements of %WS1%/resume.tex .
[12:24:37][Cacher] Updated bibs of %WS1%/resume.tex .
[12:24:37][Cacher] Cached %WS1%/resume.tex .
[12:24:37][Cacher][Path] Non-existent .fls for %WS1%/resume.tex .
[12:24:37][Linter] ChkTeX lints root %WS1%/resume.tex .
[12:24:37][Linter] Linter for root command The command is chktex:["-wall","-n22","-n30","-e16","-q","-f%f:%l:%c:%d:%k:%n:%m\n","%WS1%/resume.tex"].
[12:24:37][Viewer] Handle data type: open
[12:24:37][Linter] Linter for root successfully finished in 0s 131ms
[12:24:37][Linter][ChkTeX] No .chktexrc file is found to determine TabSize.
[12:24:37][Linter][ChkTeX] Logged 55 messages.
[12:24:37][Server] Preview PDF file: file://%WS1%/resume.pdf
[12:24:37][Viewer] Handle data type: loaded
[12:24:40][Manager] Current workspace folders: ["file://%WS1%"]
[12:24:40][Manager] Found root file from active editor: %WS1%/resume.tex
[12:24:40][Manager] Keep using the same root file: %WS1%/resume.tex
[12:24:40][Linter] ChkTeX lints root %WS1%/resume.tex .
[12:24:40][Linter] Linter for root command The command is chktex:["-wall","-n22","-n30","-e16","-q","-f%f:%l:%c:%d:%k:%n:%m\n","%WS1%/resume.tex"].
[12:24:40][Linter] Linter for root successfully finished in 0s 120ms
[12:24:40][Linter][ChkTeX] No .chktexrc file is found to determine TabSize.
[12:24:40][Linter][ChkTeX] Logged 55 messages.
[12:24:41][Format][TeX] Start formatting with latexindent.
[12:24:41][Format][TeX] The current platform is undefined.
[12:24:41][Format][TeX] Can not find latexindent in PATH: latexindent
[12:24:41][Format][TeX] PATH: /Users/pbb/opt/anaconda3/bin:/Users/pbb/opt/anaconda3/condabin:/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/homebrew/bin:/Users/pbb/.fig/bin:/Users/pbb/.local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin:/Library/TeX/texbin
[12:24:41][] onDidSaveTextDocument triggered: file://%WS1%/resume.tex
[12:24:41][Linter] ChkTeX lints root %WS1%/resume.tex .
[12:24:41][Linter] Linter for root command The command is chktex:["-wall","-n22","-n30","-e16","-q","-f%f:%l:%c:%d:%k:%n:%m\n","%WS1%/resume.tex"].
[12:24:41][Builder] Auto build started on saving file: %WS1%/resume.tex .
[12:24:41][Commander] BUILD command invoked.
[12:24:41][Commander] The document of the active editor: file://%WS1%/resume.tex
[12:24:41][Commander] The languageId of the document: latex
[12:24:41][Commander] Building root file: %WS1%/resume.tex
[12:24:41][Builder] Build root file %WS1%/resume.tex
[12:24:41][Builder] outDir: %WS1% .
[12:24:41][Builder] Preparing to run recipe: latexmk.
[12:24:41][Builder] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%WS1%","%WS1%/resume"].
[12:24:41][Builder] env: {}
[12:24:41][Builder] root: %WS1%/resume.tex
[12:24:41][Builder] cwd: %WS1%
[12:24:41][Builder] LaTeX build process spawned with PID 7490.
[12:24:41][Linter] Linter for root successfully finished in 0s 108ms
[12:24:41][Linter][ChkTeX] No .chktexrc file is found to determine TabSize.
[12:24:41][Linter][ChkTeX] Logged 55 messages.
[12:24:41][Cacher] Caching %WS1%/resume.tex .
[12:24:41][Cacher] Updated inputs of %WS1%/resume.tex .
[12:24:41][Cacher][Watcher] Changed %WS1%/resume.tex .
[12:24:41][DupLabel] Checking for duplicate labels: %WS1%/resume.tex .
[12:24:41][Cacher] Updated elements of %WS1%/resume.tex .
[12:24:41][Cacher] Updated bibs of %WS1%/resume.tex .
[12:24:41][Cacher] Cached %WS1%/resume.tex .
[12:24:42][Format][TeX] Start formatting with latexindent.
[12:24:42][Format][TeX] Format with command The command is latexindent:["-c","%DIR%/","%TMPFILE%","-y=defaultIndent: '%INDENT%'"].
[12:24:42][Format][TeX] Format args: ["-c","%WS1%/","%WS1%/__latexindent_temp_resume.tex","-y=defaultIndent: '  '"]
[12:24:43][Parser][TexLog] Logged 2 messages.
[12:24:43][Builder] Finished a step in recipe with PID 7490.
[12:24:43][Builder] Successfully built %WS1%/resume.tex .
[12:24:43][Viewer] Call refreshExistingViewer: {"sourceFile":"%WS1%/resume.tex"}
[12:24:43][Viewer] Refresh PDF viewer: undefined
[12:24:43][Cacher] Parsing .fls %WS1%/resume.fls .
[12:24:43][Cacher] Found .aux %WS1%/resume.tex from .fls %WS1%/resume.fls , parsing.
[12:24:43][Cacher] Parsed .aux %WS1%/resume.tex .
[12:24:43][Cacher] Parsed .fls %WS1%/resume.fls .
[12:24:43][Builder] Auto Clean invoked.
[12:24:43][Cleaner] Clean glob matched files {"globs":["*.aux","*.bbl","*.blg","*.idx","*.ind","*.lof","*.lot","*.out","*.toc","*.acn","*.acr","*.alg","*.glg","*.glo","*.gls","*.fls","*.log","*.fdb_latexmk","*.snm","*.synctex(busy)","*.synctex.gz(busy)"],"outdir":"%WS1%"} .
[12:24:43][Cleaner] Ignore folder glob patterns with globstar:  .
[12:24:43][Cleaner] Cleaning file %WS1%/resume.out .
[12:24:43][Cleaner] Cleaning file %WS1%/resume.log .
[12:24:43][Cleaner] Cleaning file %WS1%/resume.fls .
[12:24:43][Cleaner] Cleaning file %WS1%/resume.fdb_latexmk .
[12:24:43][Cleaner] Cleaning file %WS1%/resume.aux .
[12:24:43][Server] Preview PDF file: file://%WS1%/resume.pdf
[12:24:43][Viewer] Handle data type: loaded
[12:24:43][Format][TeX] Formatted %WS1%/resume.tex
[12:24:43][] onDidSaveTextDocument triggered: file://%WS1%/resume.tex
[12:24:43][Linter] ChkTeX lints root %WS1%/resume.tex .
[12:24:43][Linter] Linter for root command The command is chktex:["-wall","-n22","-n30","-e16","-q","-f%f:%l:%c:%d:%k:%n:%m\n","%WS1%/resume.tex"].
[12:24:43][Builder] Auto build started on saving file: %WS1%/resume.tex .
[12:24:43][Commander] BUILD command invoked.
[12:24:43][Commander] The document of the active editor: file://%WS1%/resume.tex
[12:24:43][Commander] The languageId of the document: latex
[12:24:43][Commander] Building root file: %WS1%/resume.tex
[12:24:43][Builder] Build root file %WS1%/resume.tex
[12:24:43][Builder] outDir: %WS1% .
[12:24:43][Builder] Preparing to run recipe: latexmk.
[12:24:43][Builder] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%WS1%","%WS1%/resume"].
[12:24:43][Builder] env: {}
[12:24:43][Builder] root: %WS1%/resume.tex
[12:24:43][Builder] cwd: %WS1%
[12:24:43][Builder] LaTeX build process spawned with PID 7551.
[12:24:43][Linter] Linter for root successfully finished in 0s 100ms
[12:24:43][Linter][ChkTeX] No .chktexrc file is found to determine TabSize.
[12:24:43][Linter][ChkTeX] Logged 55 messages.
[12:24:43][Cacher] Caching %WS1%/resume.tex .
[12:24:43][Cacher] Updated inputs of %WS1%/resume.tex .
[12:24:43][Cacher][Watcher] Changed %WS1%/resume.tex .
[12:24:43][DupLabel] Checking for duplicate labels: %WS1%/resume.tex .
[12:24:43][Cacher] Updated elements of %WS1%/resume.tex .
[12:24:43][Cacher] Updated bibs of %WS1%/resume.tex .
[12:24:43][Cacher] Cached %WS1%/resume.tex .
[12:24:44][Parser][TexLog] Logged 2 messages.
[12:24:44][Builder] Finished a step in recipe with PID 7551.
[12:24:44][Builder] Successfully built %WS1%/resume.tex .
[12:24:44][Viewer] Call refreshExistingViewer: {"sourceFile":"%WS1%/resume.tex"}
[12:24:44][Viewer] Refresh PDF viewer: undefined
[12:24:44][Cacher] Parsing .fls %WS1%/resume.fls .
[12:24:44][Cacher] Found .aux %WS1%/resume.tex from .fls %WS1%/resume.fls , parsing.
[12:24:44][Cacher] Parsed .aux %WS1%/resume.tex .
[12:24:44][Cacher] Parsed .fls %WS1%/resume.fls .
[12:24:44][Builder] Auto Clean invoked.
[12:24:44][Cleaner] Clean glob matched files {"globs":["*.aux","*.bbl","*.blg","*.idx","*.ind","*.lof","*.lot","*.out","*.toc","*.acn","*.acr","*.alg","*.glg","*.glo","*.gls","*.fls","*.log","*.fdb_latexmk","*.snm","*.synctex(busy)","*.synctex.gz(busy)"],"outdir":"%WS1%"} .
[12:24:44][Cleaner] Ignore folder glob patterns with globstar:  .
[12:24:44][Cleaner] Cleaning file %WS1%/resume.out .
[12:24:44][Cleaner] Cleaning file %WS1%/resume.log .
[12:24:44][Cleaner] Cleaning file %WS1%/resume.fls .
[12:24:44][Server] Preview PDF file: file://%WS1%/resume.pdf
[12:24:44][Cleaner] Cleaning file %WS1%/resume.fdb_latexmk .
[12:24:44][Cleaner] Cleaning file %WS1%/resume.aux .
[12:24:45][Viewer] Handle data type: loaded
[12:24:47][Commander] SHOWLOG command invoked: default
[12:24:47][Manager] Current workspace folders: ["file://%WS1%"]
[12:24:47][Manager] Found root file from active editor: %WS1%/resume.tex
[12:24:47][Manager] Keep using the same root file: %WS1%/resume.tex
[12:24:47][Linter] ChkTeX lints root %WS1%/resume.tex .
[12:24:47][Linter] Linter for root command The command is chktex:["-wall","-n22","-n30","-e16","-q","-f%f:%l:%c:%d:%k:%n:%m\n","%WS1%/resume.tex"].
[12:24:47][Linter] Linter for root successfully finished in 0s 110ms
[12:24:47][Linter][ChkTeX] No .chktexrc file is found to determine TabSize.
[12:24:47][Linter][ChkTeX] Logged 55 messages.
[12:25:51][Cacher] Caching %WS1%/resume.tex .
[12:25:51][Cacher] Updated inputs of %WS1%/resume.tex .
[12:25:51][Cacher][Watcher] Changed %WS1%/resume.tex .
[12:25:52][DupLabel] Checking for duplicate labels: %WS1%/resume.tex .
[12:25:52][Cacher] Updated elements of %WS1%/resume.tex .
[12:25:52][Cacher] Updated bibs of %WS1%/resume.tex .
[12:25:52][Cacher] Cached %WS1%/resume.tex .
[12:27:12][Commander] SHOWLOG command invoked: default
[12:27:13][Commander] SHOWLOG command invoked: default

p.s. the above is the log when compiling twice. The second time it correctly find latexindent.

Developer Tools Console [Required]

To access the log, click 'help' -> 'Toggle Developer Tools' -> 'Console'. Paste anything suspicious.

Can not find latexindent in PATH.
c @ notificationsAlerts.ts:42

Screenshots

If applicable, add screenshots to help explain your problem.

image image

In addition, I didn't modify any setting for latexindent, i.e.,

image

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.

jlelong commented 1 year ago

I do confirm the issue.

jlelong commented 1 year ago

@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.

James-Yu commented 1 year ago

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.

James-Yu commented 1 year ago

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.

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 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.

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).

James-Yu commented 1 year ago

It takes a bit effort to make latexindent work with Actions, yet finally we have 98e4c8e13fdd8b670475440c7abcea69d2ee292d to test formatter. Next are new tests, gradddduuuuaaaaly

jlelong commented 1 year ago

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

https://github.com/James-Yu/LaTeX-Workshop/blob/2262f03a211256137bc0968de3c684b26213c7db/src/providers/latexformatter.ts#L55-L61

James-Yu commented 1 year ago

Nice catch! Both fixed in 2508e74d