editorconfig-vim
editorconfig-vim copied to clipboard
Keep filename displayed when jumping to a buffer
Fixes: https://github.com/editorconfig/editorconfig-vim/issues/144#issue-593410179
Scott, thanks for this PR! What cases have you tested? E.g.:
- Opening files that are UTF-8 vs. opening files with other encodings
-
.editorconfig
file listing an encoding, or not - Different
fileencodings
values
I'd like to have some data that this will likely work for the majority of users. Thanks!
Hi Chris. Ya, this PR would potentially only help utf-8 users (I'm guessing around 90% or more of users are using utf-8). Ideally, a solution to this problem would help all users but will require more digging into the internals of editorconfig and possibly vim to see what processes are going on. Let me know if a PR like this one could be merged or if a 100% fix is required.
I don't think we need a 100% fix, but I would like to have some basis for believing we won't be inundated with support requests all of a sudden when we release this :) .
Great! Looks like you guys have a test file editorconfig_spec.rb
that would be helpful but I'm having trouble getting all the tests passing on the master branch even before any edits I would make. I'm getting 48 errors one of which is below as an example. Any help would be appreciated:
2) plugin/editorconfig.vim 4_tab.txt
Failure/Error: expect(vim.echo("&l:#{key}")).to eq(val)
expected: "4"
got: "8"
(compared using ==)
# ./spec/editorconfig_spec.rb:21:in `block in test_editorconfig'
# ./spec/editorconfig_spec.rb:20:in `each'
# ./spec/editorconfig_spec.rb:20:in `test_editorconfig'
# ./spec/editorconfig_spec.rb:61:in `block (2 levels) in test_instance'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
# /Users/scottperlitch/.gem/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
Would you attach or otherwise upload your testcase? I'll try to reproduce it. Thanks! Sorry you're having trouble.
No problem: testcase.txt
Hi Chris. Just wanted to follow-up and see if I can provide any more info.
Thanks for checking back! I haven't forgotten, but no progress yet on this issue. I appreciate your patience!
How about removing BOM manually when &enc
is not utf-8?
function! editorconfig_core#ini#read_ini_file(config_filename, target_filename)
if !filereadable(a:config_filename)
return {}
endif
try
let l:lines = readfile(a:config_filename)
if &encoding !=? 'utf-8'
" strip BOM
if len(l:lines) > 0 && l:lines[0][:2] ==# "\xEF\xBB\xBF"
let l:lines[0] = l:lines[0][3:]
endif
endif
let result = s:parse(a:config_filename, a:target_filename, l:lines)
catch
" rethrow, but with a prefix since throw 'Vim...' fails.
throw 'Could not read editorconfig file at ' . v:throwpoint . ': ' . string(v:exception)
endtry
return result
endfunction
There's no need to change &enc
at all.
@scottperlitch would you please see if @k-takata 's #186 solves the issue for you?
Edit I looked at the test failures you saw. Please check out #183 locally and run ./tests/travis-test.sh plugin
. If you were running rspec directly, the failures might have been due to unset $EDITORCONFIG_VIM_EXTERNAL_CORE
.
Apologies for the long delay!
No problem. It does fix the issue I was seeing! When trying to run ./tests/travis-test.sh plugin
I'm getting the following error:
+ export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig
+ EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig
+ bundle exec rspec tests/plugin/spec/editorconfig_spec.rb
Testing default
bundler: failed to load command: rspec (/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/bin/rspec)
Vimrunner::NoSuitableVimError: No suitable Vim executable could be found for this system.
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/vimrunner-0.3.1/lib/vimrunner/platform.rb:25:in `vim'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/vimrunner-0.3.1/lib/vimrunner.rb:25:in `start'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb:4:in `create_vim'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb:134:in `block in <top (required)>'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb:136:in `<top (required)>'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `load'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `each'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:102:in `setup'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/bin/rspec:23:in `load'
/Users/scott/dotfiles/vim/.vim/plugged/editorconfig-vim/tests/plugin/vendor/bundle/ruby/2.6.0/bin/rspec:23:in `<top (required)>'
@scottperlitch
- Just to check, did you install the dependencies listed in
tests/plugin/Gemfile
? I have to ask :) . - I checked the list of required vim features. Would you please check your vim/gvim's
:version
output and make sure those are listed? Looks like+clientserver
, plus+xterm_clipboard
for terminal vims.