justinmk / vim-sneak

The missing motion for Vim :athletic_shoe:
http://www.vim.org/scripts/script.php?script_id=4809
MIT License
3.26k stars 88 forks source link

regression of indentLine bug #48 and #65 #227

Closed sunaku closed 6 years ago

sunaku commented 6 years ago

Hello,

The bug described in issues #48 and #65 has returned as of Jun 26, 2017 in https://github.com/justinmk/vim-sneak/issues/48#issuecomment-311248570

Thanks for your consideration.

justinmk commented 6 years ago

what does :version say, specifically what is your vim/nvim version?

sunaku commented 6 years ago

Please see below. 🤓 I'm able to reproduce the problem every time under each of these environments.

NeoVim on Debian buster

:version
NVIM v0.2.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-VavapE/neovim-0.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdat
e-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32
 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fal
lthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-VavapE/neovim-0.2.2/bu
ild/config -I/build/neovim-VavapE/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/in
clude -I/build/neovim-VavapE/neovim-0.2.2/build/src/nvim/auto -I/build/neovim-VavapE/neovim-0.2.2/build/include
Compiled by pkg-vim-maintainers@lists.alioth.debian.org

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
Press ENTER or type command to continue

Vim on Debian buster

:version
VIM - Vi IMproved 8.1 (2018 May 17, compiled Jun 20 2018 02:44:05)
Included patches: 1-89
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               +cryptv            -footer            +mksession         +path_extra        +syntax            +viminfo
+arabic            +cscope            +fork()            +modify_fname      +perl              +tag_binary        +vreplace
+autocmd           +cursorbind        +gettext           +mouse             +persistent_undo   +tag_old_static    +wildignore
-autoservername    +cursorshape       -hangul_input      -mouseshape        +postscript        -tag_any_white     +wildmenu
-balloon_eval      +dialog_con        +iconv             +mouse_dec         +printer           +tcl               +windows
+balloon_eval_term +diff              +insert_expand     +mouse_gpm         +profile           +termguicolors     +writebackup
-browse            +digraphs          +job               -mouse_jsbterm     -python            +terminal          -X11
++builtin_terms    -dnd               +jumplist          +mouse_netterm     +python3           +terminfo          -xfontset
+byte_offset       -ebcdic            +keymap            +mouse_sgr         +quickfix          +termresponse      -xim
+channel           +emacs_tags        +lambda            -mouse_sysmouse    +reltime           +textobjects       -xpm
+cindent           +eval              +langmap           +mouse_urxvt       +rightleft         +timers            -xsmp
-clientserver      +ex_extra          +libcall           +mouse_xterm       +ruby              +title             -xterm_clipboard
-clipboard         +extra_search      +linebreak         +multi_byte        +scrollbind        -toolbar           -xterm_save
+cmdline_compl     +farsi             +lispindent        +multi_lang        +signs             +user_commands
+cmdline_hist      +file_in_path      +listcmds          -mzscheme          +smartindent       +vertsplit
+cmdline_info      +find_in_path      +localmap          +netbeans_intg     +startuptime       +virtualedit
+comments          +float             +lua               +num64             +statusline        +visual
+conceal           +folding           +menu              +packages          -sun_workshop      +visualextra
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-AUXFSU/vim-8.1.0089=. -fstack-protector-strong -W
format -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim
    -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-l
inux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -
L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm
Press ENTER or type command to continue

NeoVim on CentOS 6.7

:version
NVIM v0.3.1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -Wconversion -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector --param ssp-buffer-size=4 -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_
HAS_VAR_FROM -I/home/utils/src/neovim-0.3.1/build/config -I/home/utils/src/neovim-0.3.1/src -I/home/utils/src/neovim-0.3.1/.deps/usr/include -I/usr/include -I/home/utils/src/neovim-0.3.1/build/src/nvim/auto -I/home/utils/src/neovim-0.3.1/build/include
Compiled by root@c6build64

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/utils/neovim-0.3.1/share/nvim"

Run :checkhealth for more info
Press ENTER or type command to continue

Vim on CentOS 6.7

:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov  3 2016 12:12:45)
Included patches: 1-2
Compiled by root@c5build64
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +conceal         +file_in_path    +libcall         +mouse_sgr       +profile         +tag_old_static  +viminfo
+arabic          +cryptv          +find_in_path    +linebreak       -mouse_sysmouse  -python          -tag_any_white   +vreplace
+autocmd         +cscope          +float           +lispindent      +mouse_urxvt     -python3         -tcl             +wildignore
+balloon_eval    +cursorbind      +folding         +listcmds        +mouse_xterm     +quickfix        +termguicolors   +wildmenu
+browse          +cursorshape     -footer          +localmap        +multi_byte      +reltime         +terminfo        +windows
++builtin_terms  +dialog_con_gui  +fork()          +lua             +multi_lang      +rightleft       +termresponse    +writebackup
+byte_offset     +diff            +gettext         +menu            -mzscheme        -ruby            +textobjects     +X11
+channel         +digraphs        -hangul_input    +mksession       +netbeans_intg   +scrollbind      +timers          -xfontset
+cindent         +dnd             +iconv           +modify_fname    +num64           +signs           +title           +xim
+clientserver    -ebcdic          +insert_expand   +mouse           +packages        +smartindent     +toolbar         +xpm
+clipboard       +emacs_tags      +job             +mouseshape      +path_extra      +startuptime     +user_commands   +xsmp_interact
+cmdline_compl   +eval            +jumplist        +mouse_dec       -perl            +statusline      +vertsplit       +xterm_clipboard
+cmdline_hist    +ex_extra        +keymap          +mouse_gpm       +persistent_undo -sun_workshop    +virtualedit     -xterm_save
+cmdline_info    +extra_search    +lambda          -mouse_jsbterm   +postscript      +syntax          +visual
+comments        +farsi           +langmap         +mouse_netterm   +printer         +tag_binary      +visualextra
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/home/utils/vim-8.0-lua/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/incl
ude/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12     -DLUA_32
BITS -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/lib64    -L/usr/local/lib -Wl,--as-needed -o vim   -L/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.
0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl  -lselin
ux -lacl -lattr -lgpm  -L/home/utils/lua-5.3.1/lib -llua
Press ENTER or type command to continue
justinmk commented 6 years ago

If you revert https://github.com/justinmk/vim-sneak/commit/6244662b2583403e6d06b3eb54c46edeca8a38b5 is it fixed ?

sunaku commented 6 years ago

No luck in all 4 environments. 😞 Reverting 6244662b2583403e6d06b3eb54c46edeca8a38b5 didn't fix it. 😅

justinmk commented 6 years ago

if you can bisect to the commit that caused it I'll try to fix it.

sunaku commented 6 years ago

Git bisection found commit bd38a5235ba0bae01e8e1a6661a1136388d609bf to be the culprit:

master ~/.vim/bundle/motion/sneak> git bisect start                       #25Jul5:30pm
master git-bisect ~/.vim/bundle/motion/sneak> git bisect bad              #25Jul5:30pm
master git-bisect ~/.vim/bundle/motion/sneak> git bisect good e990c66137dfe158964e58ebbf752afcfae000ea
Bisecting: 65 revisions left to test after this (roughly 6 steps)
[1cbeb84a333f49789c15a6cc8beca9e082b85a93] test: scriptencoding
1cbeb84... git-bisect ~/.vim/bundle/motion/sneak> git bisect good         #25Jul5:31pm
Bisecting: 32 revisions left to test after this (roughly 5 steps)
[0efb506fdab951134093f1553f2e1c7348b56218] streak: avoid unfolding foldmethod=syntax
0efb506... git-bisect ~/.vim/bundle/motion/sneak> git bisect good         #25Jul5:32pm
Bisecting: 16 revisions left to test after this (roughly 4 steps)
[a0716cd57b2370a69905026a102b05f20646cb31] label-mode: <BS> or <S-Tab> to change direction
a0716cd... git-bisect ~/.vim/bundle/motion/sneak> git bisect bad          #25Jul5:32pm
Bisecting: 7 revisions left to test after this (roughly 3 steps)
[6fe28f104a3614097db42baf174ba1662aeef4f2] label-mode: default Cursor highlight
6fe28f1... git-bisect ~/.vim/bundle/motion/sneak> git bisect bad          #25Jul5:32pm
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[f00084c6f9e28e8836c3e4b5dc7e255098843a10] Simplify highlighting.
f00084c... git-bisect ~/.vim/bundle/motion/sneak> git bisect bad          #25Jul5:32pm
Bisecting: 1 revision left to test after this (roughly 1 step)
[ec2308e106ef752e5288dfc2fb538991b0eaac12] rename <Plug>SneakNext to <Plug>Sneak_;
ec2308e... git-bisect ~/.vim/bundle/motion/sneak> git bisect bad          #25Jul5:32pm
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[bd38a5235ba0bae01e8e1a6661a1136388d609bf] rename "Streak mode" to "Label mode"
bd38a52... git-bisect ~/.vim/bundle/motion/sneak> git bisect bad          #25Jul5:33pm
bd38a5235ba0bae01e8e1a6661a1136388d609bf is the first bad commit
commit bd38a5235ba0bae01e8e1a6661a1136388d609bf
Author: Justin M. Keyes <justinkz@gmail.com>
Date:   Tue Nov 29 11:35:07 2016 +0100

    rename "Streak mode" to "Label mode"

    Because:
      - "Label mode" is more intuitive
      - "Streak" may be confused with "Sneak"

    Non-breaking changes:
      rename <Plug>(SneakStreak)         to <Plug>SneakLabel_s
      rename <Plug>(SneakStreakBackward) to <Plug>SneakLabel_S
      rename SneakStreakCursor           to SneakCursor

    Breaking changes (highlight groups):
      rename SneakPluginScope  to SneakScope
      rename SneakTarget       to SneakPluginTarget
      rename SneakStreakTarget to SneakLabelTarget
      rename SneakStreakMask   to SneakLabelMask

:100644 100644 f72e0f213481404f17308612352bcd33ddb989c9 aa2e4337d8f852bf59123cc42087712d2c2d9309 M     README.md
:040000 040000 469b233ce68744c051a95e3b3ceec7d5e4f43d26 c25877c75510c6b861f9826e7200feb8675556c9 M     autoload
:040000 040000 224b935e1f2cb7a11eba48099a93d2a143d6ac2d 0027744cd4ee15f06e515b443abbaa5417c963c0 M     doc
:040000 040000 e62f10e6723e7d6b3246484548530579c9c5b645 3834db9620ca903ec57dd6fa57da53e0ffc7f75d M     plugin
:040000 040000 fa0924d4efe8cd641a290a09a07dac57629c6832 00d7ddbed12cb535e58d391f82e7d0c5fc69254c M     tests
sunaku commented 6 years ago

Interesting! 😮 I was able to stop the problem from happening by commenting out this line in my vimrc:

let g:sneak#label = 1

Here is the relevant portion of my vimrc for your review:

let g:sneak#prompt = 'Sneak: '

" case sensitivity
let g:sneak#use_ic_scs = 1

" clever repetition
let g:sneak#s_next = 1
let g:sneak#f_reset = 1
let g:sneak#t_reset = 1
" let g:sneak#absolute_dir = 1

" target selection
let g:sneak#label = 1 " <=== THIS LINE TRIGGERS THE BUG!!! :-O
let g:sneak#label_esc = "\<CR>"
let g:sneak#target_labels = 'aoeuidhtnspyfgcrlqjkxbmwvzAOEUIDHTNSPYFGCRLQJKXBMWVZ'
sunaku commented 6 years ago

I looked into the source code of both the sneak and indentLine plugins and I have concluded that this problem seems to be unavoidable because both plugins use concealed characters in the current window. 😞

The next best thing I could do was to prevent highlighting concealed characters with SneakLabel style:

diff --git a/autoload/sneak/label.vim b/autoload/sneak/label.vim
index 88bb07f..a892997 100644
--- a/autoload/sneak/label.vim
+++ b/autoload/sneak/label.vim
@@ -163,7 +163,7 @@ func! s:before() abort
   let s:orig_hl_conceal = sneak#hl#links_to('Conceal')
   let s:orig_hl_sneak   = sneak#hl#links_to('Sneak')
   "set temporary link to our custom 'conceal' highlight
-  hi! link Conceal SneakLabel
+  " hi! link Conceal SneakLabel
   "set temporary link to hide the sneak search targets
   hi! link Sneak SneakLabelMask

This creates a less user-friendly effect (sneak labels are less readable) but seems to be workable because I can still use Sneak's jarring magenta colors to guide my eye to the location I want and then read the concealed sneak label character immediately to its left: screenshot 2018-08-02 at 5 15 30 pm

🤔 It's not perfect 😓 but at the same time, it's not a show stopper either. 😅 Could this be a new option?

sunaku commented 6 years ago

Never mind 😅 the hindrance to usability outweighs the benefits of this workaround. ⚖️

I'm closing this issue since it can't be fixed: both plugins use conceal simultaneously.

It's better to just live with this issue: a small price to pay for Sneak's awesomeness! 💯

Thanks for considering my request and for creating Sneak for vim. 💖🙇🙏 Cheers!

harryjubb commented 5 years ago

Having this problem with NeoVim 0.3.1 and the current versions of sneak and indentLine.

Please forgive the novice question from someone with no knowledge of writing Vim plugins:

Easymotion doesn't seem to have this issue: is it possible to use the same method that Easymotion uses to pop out the letters to navigate to? Presumably it would lose the highlighting but still be able to show what to press from sneak#label?

justinmk commented 5 years ago

Easymotion doesn't seem to have this issue: is it possible to use the same method that Easymotion uses to pop out the letters to navigate to?

Sneak uses the "conceal" feature, which is also used by indentLine, hence the conflict.

EasyMotion edits the buffer contents temporarily, then uses undo hacks to fix the buffer later. If you're cool with that, use EasyMotion. It's out of scope for Sneak.

harryjubb commented 5 years ago

Thanks for your reply, I see what you mean. I prefer Sneak :slightly_smiling_face: so I'll live with it.