t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

'Show Invisibles' setting doesn't work if vim-mode-plus is enabled when Atom starts up #1021

Closed philgyford closed 6 years ago

philgyford commented 6 years ago

If I:

  1. Disable all Community Packages
  2. Quit Atom
  3. Open Atom

Then the 'Show Invisibles' option in Settings > Editor works as expected - invisible characters appear and disappear. If I enable vim-mode-plus at this point, 'Show Invisibles' still works.

But, if I:

  1. Disable all Community Packages except vim-mode-plus
  2. Quit Atom
  3. Open Atom

Then the 'Show Invisibles' option has no effect. If invisible characters are currently visible, they remain visible no matter how I change the setting. And if they're currently invisible, they remain invisible. If I disable vim-mode-plus at this point then 'Show Invisibles' still no longer works.

$ atom --version
Atom    : 1.23.3
Electron: 1.6.15
Chrome  : 56.0.2924.87
Node    : 7.4.0

vim-mode-plus version: 1.26.0

t9md commented 6 years ago

Interesting issue. At this point, I can't decide whether this is bug of vmp or atom itself. Btw, I haven't experienced it.

I frequently toggle invisible chars while editing via shortcut invoking custom toggle-invisible command in init.js.

https://github.com/t9md/dotfiles/blob/a36f604f01f04fcb8ef98b0badfa9ba4397c1505/atom/init.js#L157-L160

Of course I tried clicking to toggle this setting from settings > editor menu this time. But have no issue, can hide/show invisible special characters.

I'm really interesting what behavior of vmp startup can break showInvisibles feature.

Did you tried with default syntax theme? what syntax theme you use?

philgyford commented 6 years ago

Aha, init.js! I'd forgotten all about that...

It turns out I had the below in my init.coffee, and something about that was preventing this setting from working. Judging by current instructions this is outdated now.

######################################################################
# Extending vim-mode-plus

# General service consumer function
# From https://github.com/t9md/atom-vim-mode-plus/wiki/ExtendVimModePlusInInitFile#overview
consumeService = (packageName, providerName, fn) ->
  if atom.packages.isPackageActive(packageName)
    pack = atom.packages.getActivePackage(packageName)
    fn(pack.mainModule[providerName]())
  else
    disposable = atom.packages.onDidActivatePackage (pack) ->
      if pack.name is packageName
        disposable.dispose()
        fn(pack.mainModule[providerName]())

# In vim-mode-plus, stop `d` putting the delete text on the clipboard.
# Add this to keymap too:
# 'atom-text-editor.vim-mode-plus:not(.insert-mode)':
#   '\\ d': 'vim-mode-plus-user:delete-with-backhole-register'
# From https://github.com/t9md/atom-vim-mode-plus/wiki/ExtendVimModePlusInInitFile#advanced-deletewithbackholeregister
consumeService 'vim-mode-plus', 'provideVimModePlus', (service) ->
  {Base} = service

  Delete = Base.getClass('Delete')
  class DeleteWithBackholeRegister extends Delete
    @commandPrefix: 'vim-mode-plus-user'
    @registerCommand()
    execute: ->
      @vimState.register.name = "_"
      super

I can't get the newer version of DeleteWithBackholeRegister working - I get 'Unexpected token .' with it in my init.js, but that's a different problem!