sindresorhus / editorconfig-sublime

Sublime Text plugin for EditorConfig - Helps developers maintain consistent coding styles between different editors
MIT License
1.77k stars 108 forks source link

fix expand tabs when save #95 #97

Closed mercurykd closed 2 years ago

mercurykd commented 2 years ago

Fixes #95

sindresorhus commented 2 years ago

Can you explain your change? (Why it's correct)

mercurykd commented 2 years ago

image

  1. open a file in a project with tabs
  2. The editorconfig setting says to use spaces - set the translate_to_space flag to True
  3. when saving the file, we identify spaces or tabs by the flag that we ourselves set earlier to True
  4. expand_tabs won't work because translate_to_space can't be False
mercurykd commented 2 years ago

detect_indentation returns the translate_to_spaces flag according to the presence of tabs in the file

risingphoenix commented 2 years ago

Since the last update, sublime has unexpected behavior whereby, for me, it was necessary to disable the extension. When I open the file everything is correct, while after saving, the indentation is always viaually reduced to 2 even if the setting is 4 and changed some initial spaces to tabs

I forward you the source file and the configuration

BEFORE SAVE - Visually Tab Width: 4

{{--
    ____                        __     ____
   / __ \___  ____  ____  _____/ /_   / __ )____ ______
  / /_/ / _ \/ __ \/ __ \/ ___/ __/  / __  / __ `/ ___/
 / _, _/  __/ /_/ / /_/ / /  / /_   / /_/ / /_/ / /
/_/ |_|\___/ .___/\____/_/   \__/  /_____/\__,_/_/
          /_/
--}}

<report-bar title="{{ $session->type->name }}" subtitle="Risult"></report-bar>

{{--
  _______ __  __
 /_  __(_) /_/ /__
  / / / / __/ / _ \
 / / / / /_/ /  __/
/_/ /_/\__/_/\___/

--}}

@include('reports.components.section_title', [])

@component('report::section')

    Lorem ipsum, dolor sit amet consectetur adipisicing elit. Perferendis, et?

    Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Quia, dicta.

    Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Nostrum, consequatur!

@endcomponent

AFTER SAVE - Visually Tab Width: 2 setted automatically


{{--
        ____                        __     ____
     / __ \___  ____  ____  _____/ /_   / __ )____ ______
    / /_/ / _ \/ __ \/ __ \/ ___/ __/  / __  / __ `/ ___/
 / _, _/  __/ /_/ / /_/ / /  / /_   / /_/ / /_/ / /
/_/ |_|\___/ .___/\____/_/   \__/  /_____/\__,_/_/
                    /_/
--}}

<report-bar title="{{ $session->type->name }}" subtitle="Risult"></report-bar>

{{--
    _______ __  __
 /_  __(_) /_/ /__
    / / / / __/ / _ \
 / / / / /_/ /  __/
/_/ /_/\__/_/\___/

--}}

@include('reports.components.section_title', [])

@component('report::section')

    Lorem ipsum, dolor sit amet consectetur adipisicing elit. Perferendis, et?

    Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Quia, dicta.

    Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Nostrum, consequatur!

@endcomponent

.editorconfig

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
trim_trailing_whitespace = true
indent_size = 4

Preferences.sublime-settings

"detect_indentation": false,
"ensure_newline_at_eof_on_save": false,
"trim_trailing_white_space_on_save": "none",

other preferences are at default value

"tab_size": 4,
"translate_tabs_to_spaces": false,

Many thanks for any help or suggestion

sindresorhus commented 2 years ago

@risingphoenix Since @mercurykd has not responded, this pull request has been reverted.

https://github.com/sindresorhus/editorconfig-sublime/releases/tag/v1.0.2

mercurykd commented 2 years ago

I just pointed out that the line view.run_command('expand_tabs', {'set_translate_tabs': True}) will never work without view.run_command('detect_indentation'). why @risingphoenix does not work the way he wants, you need to understand separately.