sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
811 stars 80 forks source link

Tab Width not applying correctly when different from Indent Size #198

Closed software-opal closed 1 year ago

software-opal commented 7 years ago

I'm working on a project that uses 2-space indentation for code blocks, however uses tab indentation for intra-line indentation which uses 8-character-width tab characters.

Example code:

my_var =        "value"
my_var_with_long_name = "another"
if my_var == "value":
  short = "val"

I've set up the editor config as follows:

root = true
[*]
indent_style = space
indent_size = 2
tab_width = 8

However the code that is displayed in Atom is(replacing tabs with spaces to show incorrect indentation):

my_var =    "value"
my_var_with_long_name =  "another"
if my_var == "value":
  short = "val"

My understanding of the spec is that the tab_width setting should change the length of tabs to be(in this case) 8.

Installed packages

Built-in Atom Packages (91)
├── atom-dark-syntax@0.28.0
├── atom-dark-ui@0.53.0
├── atom-light-syntax@0.29.0
├── atom-light-ui@0.46.0
├── base16-tomorrow-dark-theme@1.5.0
├── base16-tomorrow-light-theme@1.5.0
├── one-dark-ui@1.10.4
├── one-light-ui@1.10.4
├── one-dark-syntax@1.7.1
├── one-light-syntax@1.7.1
├── solarized-dark-syntax@1.1.2
├── solarized-light-syntax@1.1.2
├── about@1.7.6
├── archive-view@0.63.2
├── autocomplete-atom-api@0.10.1
├── autocomplete-css@0.16.2
├── autocomplete-html@0.8.0
├── autocomplete-plus@2.35.4
├── autocomplete-snippets@1.11.0
├── autoflow@0.29.0
├── autosave@0.24.3
├── background-tips@0.27.0
├── bookmarks@0.44.4
├── bracket-matcher@0.85.5
├── command-palette@0.40.4
├── dalek@0.2.1
├── deprecation-cop@0.56.7
├── dev-live-reload@0.47.1
├── encoding-selector@0.23.4
├── exception-reporting@0.41.4
├── find-and-replace@0.208.3
├── fuzzy-finder@1.5.8
├── github@0.3.3
├── git-diff@1.3.6
├── go-to-line@0.32.1
├── grammar-selector@0.49.5
├── image-view@0.61.2
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.38.0
├── line-ending-selector@0.7.1
├── link@0.31.3
├── markdown-preview@0.159.12
├── metrics@1.2.5
├── notifications@0.67.2
├── open-on-github@1.2.1
├── package-generator@1.1.1
├── settings-view@0.249.4
├── snippets@1.1.4
├── spell-check@0.71.4
├── status-bar@1.8.11
├── styleguide@0.49.6
├── symbols-view@0.116.0
├── tabs@0.106.2
├── timecop@0.36.0
├── tree-view@0.217.1
├── update-package-dependencies@0.12.0
├── welcome@0.36.4
├── whitespace@0.36.2
├── wrap-guide@0.40.2
├── language-c@0.58.0
├── language-clojure@0.22.2
├── language-coffee-script@0.48.7
├── language-csharp@0.14.2
├── language-css@0.42.2
├── language-gfm@0.89.0
├── language-git@0.19.1
├── language-go@0.44.0
├── language-html@0.47.2
├── language-hyperlink@0.16.1
├── language-java@0.27.1
├── language-javascript@0.126.1
├── language-json@0.19.1
├── language-less@0.32.0
├── language-make@0.22.3
├── language-mustache@0.14.1
├── language-objective-c@0.15.1
├── language-perl@0.37.0
├── language-php@0.38.0
├── language-property-list@0.9.1
├── language-python@0.45.2
├── language-ruby@0.71.0
├── language-ruby-on-rails@0.25.2
├── language-sass@0.59.0
├── language-shellscript@0.25.0
├── language-source@0.9.0
├── language-sql@0.25.5
├── language-text@0.7.2
├── language-todo@0.29.1
├── language-toml@0.18.1
├── language-xml@0.35.0
└── language-yaml@0.29.0

Community Packages (56) /home/lee/.atom/packages
├── MagicPython@1.0.10
├── ariake-dark-syntax@0.1.3
├── atom-django@0.3.2
├── atom-jinja2@0.6.0
├── atom-material-syntax@1.0.6
├── atom-material-ui@2.0.4
├── busy-signal@1.4.3
├── django-templates@0.5.0
├── editorconfig@2.2.2
├── escape-utils@0.5.3
├── git-plus@7.9.3
├── glacier-dark-ui@0.5.0
├── glacier-ui@0.2.5
├── gloom@0.6.4
├── intentions@1.1.2
├── language-ansible@0.2.1
├── language-docker@1.1.8
├── language-ini@1.19.0
├── language-liquid@0.6.0
├── language-nginx@0.8.0
├── language-puppet@0.23.0
├── language-restructuredtext@1.1.0
├── language-rust@0.4.11
├── language-svg@0.9.2
├── language-tks@0.2.0
├── linter@2.2.0
├── linter-alex@4.0.0
├── linter-ansible-linting@1.3.0
├── linter-csslint@1.3.4
├── linter-docker@0.2.0
├── linter-eslint@8.2.1
├── linter-flake8@2.2.1
├── linter-phpcs@1.6.7
├── linter-rust@0.8.0
├── linter-sass-lint@1.7.4
├── linter-scss-lint@3.1.0
├── linter-shellcheck@1.4.4
├── linter-ui-default@1.6.2
├── local-history@4.3.0
├── minimap@4.28.3
├── minimap-bookmarks@0.4.2
├── minimap-cursorline@0.2.0
├── minimap-find-and-replace@4.5.2
├── minimap-git-diff@4.3.1
├── minimap-linter@2.0.0
├── minimap-selection@4.4.0
├── nord-atom-syntax@0.9.1
├── nord-atom-ui@0.11.0
├── northem-dark-atom-syntax@2.1.0
├── northem-dark-atom-ui@2.1.0
├── pigments@0.39.1
├── pretty-json@1.6.3
├── sort-lines@0.14.0
├── svg-preview@0.11.0
├── test@0.0.0
└── text-manipulation@0.6.0
florianb commented 7 years ago

Hi @leesdolphin - thank you very much for getting in touch.

This is an interesting approach but i fear besides of the fact that this isn't how the editorconfig-values are currently applied Atom does unfortunately not support the differentiation between indentation and intra-line tabs.

Currently indent_size and tab_width fall back to each other if one isn't defined and since Atom does not differentiate between both, we're just setting the tab length and character.

software-opal commented 7 years ago

So it looks there is a Issue open on Atom to separate the tab-character-width and the indent. But it appears to have dropped off the radar: https://github.com/atom/atom/issues/12931

tukusejssirs commented 6 years ago

I’ve just found out that setting indent_size or tab_width to 3 (or any value really) makes the indent/width one more (4).

# .editorconfig:
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true

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

# Show state of .editorconfig:
end_of_line | \n
-- | --
charset | utf8
indent_style | tab
indent_size/ tab_width | 3
insert_final_newline | false
trim_trailing_whitespace | true
max_line_length | auto

I use Atom 1.26.0 x64 on Xubuntu 17.10 AMD64.

sindresorhus commented 1 year ago

Closing as Atom is abandoned.