sindresorhus / atom-editorconfig

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

Respect the actual line indent size instead of the defined indent_size #200

Closed fpuga closed 1 year ago

fpuga commented 6 years ago

I'm not sure if this is a bug or a feature, but right now instead of using the defined indent_size if you are typing in a line that is already indented the indent size used is the one of the actual ones and not the one in the configuration.

Steps to reproduce:

  1. Create a file like this one
def foo():
    print('hello world')
  1. Pressing enter with the cursor in the line 1 the new line will have 2 spaces.
  2. Pressing enter with the cursor in the line 2 the new line will have 4 spaces.

Involved .editorconfig-files

root = true
[*]
indent_size=2

Directory structure

.edittorconfig
foo.py
florianb commented 6 years ago

Hi @fpuga - thanks for getting in touch. I will take a look at this (i guess next week), but i fear this isn't anything we can handle in this package. The reason is that we're setting the buffer's indentation in a general setting and Atom is applying the settings to the newlines independently.

fpuga commented 6 years ago

Thanks for sharing your thoughts. As I say, this can be the expected behaviour for some users. Maybe is just a matter of taste. For example, emacs, also have some weird behaviours in this topic. If the electric-indent-mode is enabled (and it is by default), when you press enter on a line, the current line and the next line are both indented. So I understand that it does not have an easy fix.

florianb commented 6 years ago

Thanks for that hint @fpuga - this sounds pretty interesting. I think editorconfig doesn't cover that feature in general but i'll have a look.

sindresorhus commented 1 year ago

Closing as Atom is abandoned.