Sublime Forum

Detect indentation with 3 spaces is broken

#1

Hello there,

As I mentioned in the title, i dont know why but the indentation with 3 spaces is broken in PHP files with “DocComment” in Windows. 2 or 4 spaces are work well but 3 or 5 spaces are not.

If i write any code in php with phpdoc and 3 spaces it works good without saving it. But when I save the file, close the file and open that file again, indentation cannot be detected almost every time (10-9, 10-8). But sometimes (10-1) it works. I really dont understand what the problem. I really love sublime text, i dont want to download vscode or atom. Sublimetext is the best editor for me but also i am obsessed with 3spaces. :slight_smile: I cannot give up neither Sublime Text nor 3 spaces-coding.

I tried to disable detect_indentation setting but this one is not what i wanted.

And last, I haven’t installed any plug-ins yet.

Here is my settings:

My Sublime Text Version: Build 3207
My OS: Windows 10

    {
	"tab_size": 3,
        "translate_tabs_to_spaces": true,
        "detect_indentation": true,
        "use_tab_stops": true,
        "smart_indent": true,
        "auto_indent": true,
    }

What i wanted; (Not Broken)

What it looks like (Broken)

Sample Code

class Test extends TestAbstract implements TestInterface {
   
   /**
    * Lorem ipsum dolor sit amet 
    * Lorem ipsum dolor sit amet
    * 
    * @param string $test
    * @param array $testArray
    */
   public function __construct (string $test, array $testArray) {
      if ($test == $testArray) {
         return false;
      } else {
         return true;
      }
   }

}

Last, I’m bad at speaking-writing English. So, sorry about grammar. :slight_smile:

0 Likes

#2

Looks good to me with https://packagecontrol.io/packages/AutoSetIndentation.
PSR-2 MUST uses 4-space indentation by the way.

2 Likes

#3

Yes i know psr standarts but for my “own” one-person projects i prefer 3spaces.

I installed that plugin now and still not working. Although 3 spaces are set in the setting file When I open the php file written with 3 spaces, 2 spaces appear to be set. When I set it back to 3 spaces and close the file (not the editor, it’s okay if I open the file after “closing the editor”.) and open it again, it happens again.

0 Likes

#4

Did you see the following message when opening a file?

If not, I suspect that the plugin is not loaded. Restart your ST then.

1 Like

#5

Another way is to create a .editorconfig file and use https://packagecontrol.io/packages/EditorConfig.

1 Like

#6

Now after i close editor and open it again, i saw that message and indentation detected correctly. Thanks a lot for the plugin suggestion. I will use the plugin until this error is resolved.

I hope sublime team fix this problem as soon as possible.

1 Like

#7

We’ve taken a new approach to detecting indentation that will be in the next release. It handles all the special cases from AutoSetIndentation correctly.

1 Like

#8

May also close issues mentioned in https://packagecontrol.io/packages/AutoSetIndentation :smile:

1 Like

#9

FYI, I marked all issues that @bschaaf is declaring as “fixed in the next release” with the 3209 milestone so we can try reproducing the issues and verify that they are indeed fixed. In this case, I also marked those referenced by AutoSetIndentation and crossreferences within the issue list because we obviously don’t know the extend of the fix.

2 Likes