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

Keep filename displayed when jumping to a buffer

Open scottperlitch opened this issue 4 years ago • 12 comments

Fixes: https://github.com/editorconfig/editorconfig-vim/issues/144#issue-593410179

scottperlitch avatar Apr 05 '20 15:04 scottperlitch

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!

cxw42 avatar Apr 06 '20 00:04 cxw42

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.

scottperlitch avatar Apr 09 '20 13:04 scottperlitch

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 :) .

cxw42 avatar Apr 10 '20 00:04 cxw42

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)>'

scottperlitch avatar Apr 18 '20 16:04 scottperlitch

Would you attach or otherwise upload your testcase? I'll try to reproduce it. Thanks! Sorry you're having trouble.

cxw42 avatar Apr 19 '20 17:04 cxw42

No problem: testcase.txt

scottperlitch avatar Apr 19 '20 17:04 scottperlitch

Hi Chris. Just wanted to follow-up and see if I can provide any more info.

scottperlitch avatar May 15 '20 20:05 scottperlitch

Thanks for checking back! I haven't forgotten, but no progress yet on this issue. I appreciate your patience!

cxw42 avatar May 15 '20 20:05 cxw42

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.

k-takata avatar May 16 '20 04:05 k-takata

@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!

cxw42 avatar Jan 22 '22 02:01 cxw42

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 avatar Jan 23 '22 13:01 scottperlitch

@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.

cxw42 avatar Jan 28 '22 02:01 cxw42