Latex-workshop: Document formatting does not consider document indentation settings

Created on 1 Jun 2018  路  8Comments  路  Source: James-Yu/LaTeX-Workshop

Description

When you format LaTeX "code" in your document, it will always format by using tabs irregardless of the documents vs-code-indentation-settings.

How to reproduce

  1. Create a LaTeX document using the plugin
  2. Write some properly formatted stuff indenting with spaces
  3. Format

Expected behavior

The document should not change.

Actual behavior

The document will now be indented with tabs.

Most helpful comment

Fixed by changing default latex-workshop.latexindent.args to

[
        "-c",
        "%DIR%/",
        "%TMPFILE%",
        "-y",
        "defaultIndent: '%INDENT%'"
]

All 8 comments

Using tabs vs spaces for formatting is based on the value of editor.insertSpaces. Does the issue appear regardless of the value of editor.insertSpaces. What is your value of editor.detectIndentation?

Both editor.insertSpaces and editor.detectIndentation are set to true.

It seems that I can reproduce this problem. Looking into that.

Quite interestingly, I cannot identify the source of this issue. It seems that the extension can correctly detect the above settings, and translate them into -y="defaultIndent:鈵b悾鈵b悾" for four spaces. However, latexindent seems to ignore this setting only when called by vscode. Scratching head and help needed.

There were actually two problems

  • arguments passed to latexindent had extra quotes
  • tabSize and insertSpaces values were wrong when detectIndentation=true.

I think I have fixed both problems but could you please check that it does work with your configuration. Reopen the issue if needed.

This bug seems to be back as of commit https://github.com/James-Yu/LaTeX-Workshop/commit/de6216719f87d27c7bd97ae3c0e85e18a27fee5c, which removes shell: true from the spawn arguments.

Fixed by changing default latex-workshop.latexindent.args to

[
        "-c",
        "%DIR%/",
        "%TMPFILE%",
        "-y",
        "defaultIndent: '%INDENT%'"
]

@jlelong I can also now reproduce the bug. The fix by @draivin works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanmcbreen picture seanmcbreen  路  4Comments

dslemusp picture dslemusp  路  4Comments

jose-a-sa picture jose-a-sa  路  4Comments

LordScree picture LordScree  路  5Comments

s-ilic picture s-ilic  路  3Comments