Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

same line \begin, \end behavior is counterlogical #2061

Closed
ArborealAnole opened this issue Apr 30, 2020 · 3 comments
Closed

same line \begin, \end behavior is counterlogical #2061

ArborealAnole opened this issue Apr 30, 2020 · 3 comments
Labels
bug Issue identified by LW maintainers as bug

Comments

@ArborealAnole
Copy link
Contributor

When embedding an environment within a single line such as \begin{bmatrix}0\\0\\1\end{bmatrix} LaTeX Workshop unnecessarily de-indents the line upon typing the second {. If the line is then re-indented manually, Workshop will indent the subsequent line once more than the current line's indentation. Can Workshop be made to instead detect that the \begin matching the \end is on the current line and therefore not de-indent?

@jlelong jlelong added the bug Issue identified by LW maintainers as bug label May 1, 2020
@jlelong
Copy link
Collaborator

jlelong commented May 1, 2020

It is not clear if we can really fix this in the extension. Indentation is handled by vscode itself, see https://code.visualstudio.com/api/language-extensions/language-configuration-guide#indentation-rules

It is easy to come up with regex that skip \begin...\end pairs on a single line. I will think of it

@jlelong jlelong closed this as completed in 61d7b1a May 1, 2020
@jlelong
Copy link
Collaborator

jlelong commented May 1, 2020

Ensuring that the line after \begin{bmatrix}0\\0\\1\end{bmatrix} is not indented is now properly fixed. This should also work fine with nested \begins. For instance, a single indentation is issued after

\begin{equation}\begin{cases} x \\ y \end{cases}

However, ensuring that the \end{ in \begin{bmatrix}0\\0\\1\end{bmatrix} does not decrease indentation is more delicate. There is no way to detect that a \end is preceded by the matching \begin. I hope only matching ^\s*\\end{ will make everyone happy. Btw, this is approach used by the html mode,

https://github.com/microsoft/vscode/blob/master/extensions/html-language-features/client/src/htmlMain.ts#L200

@ArborealAnole
Copy link
Contributor Author

Thank you for the quick attention. This solution should work well for my purposes.

jlelong added a commit that referenced this issue Nov 27, 2020
It is related to
  -  Autocomplete big paren commands PR #2397
  - Fix #2061 indentation with begin/end on the same line.
Repository owner locked as resolved and limited conversation to collaborators Jan 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by LW maintainers as bug
Projects
None yet
Development

No branches or pull requests

2 participants