Skip to content

Add autoclosing of an environment when using the latex auto fill feature when approiate#1696

Open
dam024 wants to merge 4 commits intoSublimeText:masterfrom
dam024:master
Open

Add autoclosing of an environment when using the latex auto fill feature when approiate#1696
dam024 wants to merge 4 commits intoSublimeText:masterfrom
dam024:master

Conversation

@dam024
Copy link
Copy Markdown

@dam024 dam024 commented Mar 12, 2026

This modification improves the Fill-helper autocompletion features of LaTeXTools:

  • When using the fill-helper to autocomplete an environment (\begin{), the environment is automatically closed when appropriate and the cursor is moved to the appropriate position.
  • When fill-helper completes another command than an environment, the cursor is moved after the closing bracket when appropriate
  • Settings were made to control the behavior of these new features (please, refer to these for more information)

dam024 added 4 commits March 11, 2026 23:02
If the env_auto_trigger settings is true, LaTeXTools asks the user to enter an environment name via a WindowCommand. This modification ensures that the environment is closed automatically when the user triggers this feature with \begin{...}
The following bugs have been fixed:
- When called from the latextools_fill_all TextCommand, the autoclose is not performed
- When completing another command than \begin{...}, the cursor is moved by one character, being after the closing bracket.
The new features are deactivated by default
@deathaxe
Copy link
Copy Markdown
Member

  1. "smart_cursor_move_auto_trigger": true doesn't seem to have any effect on my setup. Caret is not moved after autofill helper inserts environment name.

  2. With "env_autoclose_trigger": true corresponding \end command is unconditionally inserted, regardless a matching end command being present in the document. While this may help when adding new environments, it may be unwanted when just editing/changing existing ones.

    Just consider someone navigating into existing \begin{...}, hitting ctrl+l,ctrl+shift+n to change the name via autofill helper. With this PR 2 (broken) end commands are inserted.

  3. Behaviour of committing environment names via auto-completions and auto-fill helper should more or less be the same for consistency reasons. I consider auto-fill helper as a legacy mechanism to provide completions which dates back to days ST's auto-completions didn't exist or were not powerful enough.

  4. There are already various ways to insert matching ´\begin..\end´ commands:

    • via plain \begin snippet
    • via CWL completions
    • via ctrl+l,ctrl+n

Regardless the function being gated behind settings, it should behave in sane and consistent ways, when enabled. Otherwise it won't be used by many or will just be cause of follow up issues and/or unnecessary extra maintenance burden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants