sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
800 stars 35 forks source link

Smart indentation vs. literate programming #5856

Open diachedelic opened 1 year ago

diachedelic commented 1 year ago

Description of the bug

Recording 2023-02-05 at 10 14 13

Recording 2023-02-05 at 10 24 25

I hope the screencaps above clearly illustrate my predicament. If this is not a bug, I would really appreciate a workaround (I realise that my style is unusual). For now, I will stick with build 4126.

Steps to reproduce

  1. Start ST in safe mode.
  2. Change syntax to a language at delimits blocks with curly braces.
  3. Open a block.
  4. Inside the block, write a line comment indented to the left margin.
  5. Press enter, observe the indentation.

Expected behavior

I would like the indentation of the new line to match the previous line, as it did in previous builds of Sublime.

Actual behavior

The indentation matches the containing block.

Sublime Text build number

4143

Operating system & version

MacOS 13.1

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

keith-hall commented 1 year ago

I thought this might have had something to do with unIndentedLinePattern or TM_COMMENT_DISABLE_INDENT in the tmPreferences files, but after some quick experimenting I wasn't able to prove it. Maybe a simple solution for your use case is to write a keybinding that when you press / after / in a code file, when there is only whitespace on the line before it, that it would unindent the line. I realise that would only help for languages whose comments begin //, so another suggestion: A custom keybinding for Enter when in a comment that would create a new line and unindent it.

diachedelic commented 1 year ago

I realise that would only help for languages whose comments begin //

Actually, it looks like this problem only manifests with languages whose comments being with //. The Bash and Ruby syntaxes seem to indent nicely. Thanks for the keybinding idea, I will try it.

diachedelic commented 1 year ago

And I don't think I have any tmPreferences files (at least, I can't find any). I'm struggling to write the keybinding you describe, where the second / unindents the line. Do you know the name of the command that unindents the line?