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

[HTML] Indent Issue #915

Closed
jgbishop opened this Issue Apr 20, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@jgbishop

jgbishop commented Apr 20, 2017

I'm seeing an issue in Build 3129 that I wasn't seeing prior to updating from beta build 3126. I have attached a small GIF showing the issue (which I will then describe):

st3_bug

Here's the order of operations:

  1. I insert a new list item by typing li then pressing Tab to expand the tag.
  2. After typing some text, I press the Enter key to continue on the next line.
  3. As soon as I type a single character, the second line is magically indented, presumably to match the indention level from the previous line.
  4. Proceeding to the next line does not un-indent things so that all my li elements are aligned. In fact, I can keep increasing the indent as shown in the screenshot.

Note how the indent / unindent jumps around on the second line of item 2. I type the letter a, followed by a backspace, then b followed by another backspace, etc. I'm not sure if there's a plugin at work here or not, but I know this behavior wasn't present in the beta build.

Below are my relevant indent preferences, in case it helps. I'm seeing this in Windows, HTML syntax, tab size of 4. I also have Emmet installed, which may have a bearing on this.

  • detect_indentation: true
  • auto_indent: true
  • smart_indent: true
  • indent_to_bracket: false
  • trim_automatic_white_space: true
  • word_wrap: "auto"
  • wrap_width: 0
  • indent_subsequent_lines: true
@OdatNurd

This comment has been minimized.

Show comment
Hide comment
@OdatNurd

OdatNurd Apr 20, 2017

I've noticed an indent issue with HTML as well, which I assume is related. As noted here, when closing a tag, the indent jumps backwards an indentation level even if the cursor is already at the appropriate position.

sublime_text_3128_indent

As a contrast, in build 3126 closing a tag does not adjust the indent level in this case.

sublime_text_3126_indent

The settings in use here are the same as the OP, with theexception of wrap_width being set to 110.

OdatNurd commented Apr 20, 2017

I've noticed an indent issue with HTML as well, which I assume is related. As noted here, when closing a tag, the indent jumps backwards an indentation level even if the cursor is already at the appropriate position.

sublime_text_3128_indent

As a contrast, in build 3126 closing a tag does not adjust the indent level in this case.

sublime_text_3126_indent

The settings in use here are the same as the OP, with theexception of wrap_width being set to 110.

@keith-hall

This comment has been minimized.

Show comment
Hide comment
@keith-hall

keith-hall Apr 20, 2017

Contributor

It looks like the problem here is that the rules that increase indentation and the rules that decrease indentation don't currently sync up nicely:

  • Indentation is currently always increased when an open tag starts the line (ignoring whitespace) and isn't followed by a corresponding closing tag on the same line. It doesn't currently cope with an open tag that follows a close tag.
  • Indentation is currently always decreased when a close tag starts the line (ignoring whitespace). If there is something other than whitespace before the closing tag, it doesn't decrease the indentation.

Therefore, to fix this, we can change it so that:

  • when deciding to increase indentation on the next line, it will also consider opening tags that are not at the beginning of the line (i.e. if there is any unclosed open tag on the line then it will indent the next line).
  • when deciding to decrease indentation on the current line, it will "ignore" text that appears before the closing tag. (We could also make this "smarter" by detecting whether there are any closing tags on the line that don't have a corresponding opening tag preceding it somewhere on the same line.)
Contributor

keith-hall commented Apr 20, 2017

It looks like the problem here is that the rules that increase indentation and the rules that decrease indentation don't currently sync up nicely:

  • Indentation is currently always increased when an open tag starts the line (ignoring whitespace) and isn't followed by a corresponding closing tag on the same line. It doesn't currently cope with an open tag that follows a close tag.
  • Indentation is currently always decreased when a close tag starts the line (ignoring whitespace). If there is something other than whitespace before the closing tag, it doesn't decrease the indentation.

Therefore, to fix this, we can change it so that:

  • when deciding to increase indentation on the next line, it will also consider opening tags that are not at the beginning of the line (i.e. if there is any unclosed open tag on the line then it will indent the next line).
  • when deciding to decrease indentation on the current line, it will "ignore" text that appears before the closing tag. (We could also make this "smarter" by detecting whether there are any closing tags on the line that don't have a corresponding opening tag preceding it somewhere on the same line.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment