editorconfig-vim icon indicating copy to clipboard operation
editorconfig-vim copied to clipboard

Set shiftwidth to 0 (defaults to tabstop value)

Open gwymor opened this issue 2 years ago • 4 comments

The current behavior is to set both shiftwidth and tabstop/softtabstop. shiftwidth gets set to the same value as tabstop. If I open a file that editorconfig indents with 8-space hard tabs, then ":set tabstop=4", my shiftwidth will still be 8, meaning that when I indent I will get two tabs. Set shiftwidth to 0, which defaults to the value of tabstop, and doesn't set softtabstop either. This should have the same end result with less complication.

gwymor avatar Sep 03 '21 15:09 gwymor

Looks reasonable. Thanks for the contribution!

Unfortunately, my motherboard died, so I will not be able to test this until late next week when the new one comes in :( .

cxw42 avatar Sep 04 '21 16:09 cxw42

My PC is working again! :tada:

When I run the tests, I get failures in 4_space.py:

Failures:

  1) plugin/editorconfig.vim 4_space.py
     Failure/Error: expect(vimval).to eq(val), "key #{key} had value #{vimval}, but I expected #{val}"
       key tabstop had value 8, but I expected 4
     # ./tests/plugin/spec/editorconfig_spec.rb:22:in `block in test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `each'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:44:in `block (2 levels) in test_instance'

  2) plugin/editorconfig.vim 4_space.py
     Failure/Error: expect(vimval).to eq(val), "key #{key} had value #{vimval}, but I expected #{val}"
       key tabstop had value 8, but I expected 4
     # ./tests/plugin/spec/editorconfig_spec.rb:22:in `block in test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `each'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:44:in `block (2 levels) in test_instance'

  3) plugin/editorconfig.vim 4_space.py
     Failure/Error: expect(vimval).to eq(val), "key #{key} had value #{vimval}, but I expected #{val}"
       key tabstop had value 8, but I expected 4
     # ./tests/plugin/spec/editorconfig_spec.rb:22:in `block in test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `each'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:44:in `block (2 levels) in test_instance'

  4) plugin/editorconfig.vim 4_space.py
     Failure/Error: expect(vimval).to eq(val), "key #{key} had value #{vimval}, but I expected #{val}"
       key tabstop had value 8, but I expected 4
     # ./tests/plugin/spec/editorconfig_spec.rb:22:in `block in test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `each'
     # ./tests/plugin/spec/editorconfig_spec.rb:20:in `test_editorconfig'
     # ./tests/plugin/spec/editorconfig_spec.rb:44:in `block (2 levels) in test_instance'

Finished in 6.91 seconds (files took 0.96871 seconds to load)
64 examples, 4 failures

Do the tests pass on your machine? I did sudo apt install bundler and then ./tests/travis-test.sh plugin.

cxw42 avatar Sep 13 '21 02:09 cxw42

No, the tests weren't passing locally, but I may have missed that because I had a different version of the plugin installed which may have thrown off test results.

Am I correct in thinking that given the config:

[*]
indent_style = space
indent_size = 4
tab_width = 8

If I indent, I should get 4 spaces, and that tab_width should not have any effect on indent width, as indent_style is not tab? If so I have a fix.

gwymor avatar Sep 13 '21 04:09 gwymor

@cxw42 Did those changes fix the issue for you?

gwymor avatar Jan 08 '22 03:01 gwymor

@cxw42 This conflicts with the recently-merged #198, as this PR removes setting softtabstop entirely as it was unneeded after these changes. As that PR adds new config options affecting softtabstop, how would you like to proceed here?

In the mean time, I've rebased this PR and temporarily reverted #198 in my PR so I can continue to use the behavior of my PR.

gwymor avatar Nov 15 '22 05:11 gwymor