From c8c9dfd3bfe1b16e4ea7b4f8abefa5fbb96f5a2e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 10 Feb 2014 01:55:05 +0100 Subject: [PATCH 1/3] Do not match newlines in `highlight` output Without this, `links to Foo` might be included, which results in an error, when throwing that into a call to `highlight` to restore it. The proper fix would be to restore it as `highlight link Cursor|Error FooLink`, but that requires refactoring, since the return value for `hl_cursor_off`/`turn_off_hl_error` is used as a definition also. Fixes https://github.com/osyo-manga/vital-over/issues/23 Fixes https://github.com/Lokaltog/vim-easymotion/issues/95 --- autoload/EasyMotion.vim | 4 +++- autoload/vital/_easymotion/Over/Commandline.vim | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index c2663ee..cede8b8 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -384,7 +384,9 @@ function! s:turn_off_hl_error() "{{{ finally let &verbose = save_verbose endtry - let hl = substitute(matchstr(cursor, 'xxx \zs.*'), '[ \t\n]\+\|cleared', ' ', 'g') + " NOTE: do not match across newlines, to remove 'links to Foo' + " (https://github.com/Lokaltog/vim-easymotion/issues/95) + let hl = substitute(matchstr(cursor, 'xxx \zs[^\n]*'), '[ \t\n]\+\|cleared', ' ', 'g') if !empty(substitute(hl, '\s', '', 'g')) let s:old_hl_error = hl endif diff --git a/autoload/vital/_easymotion/Over/Commandline.vim b/autoload/vital/_easymotion/Over/Commandline.vim index 01b31f5..259bba7 100644 --- a/autoload/vital/_easymotion/Over/Commandline.vim +++ b/autoload/vital/_easymotion/Over/Commandline.vim @@ -262,7 +262,9 @@ function! s:base.hl_cursor_off() finally let &verbose = save_verbose endtry - let hl = substitute(matchstr(cursor, 'xxx \zs.*'), '[ \t\n]\+\|cleared', ' ', 'g') + " NOTE: do not match across newlines, to remove 'links to Foo' + " (https://github.com/osyo-manga/vital-over/issues/23) + let hl = substitute(matchstr(cursor, 'xxx \zs[^\n]*'), '[ \t\n]\+\|cleared', ' ', 'g') if !empty(substitute(hl, '\s', '', 'g')) let self.variables.old_hi_cursor = hl endif From a944fdf37ceb383a659d496d8955a6ff0bdaf125 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Fri, 7 Feb 2014 10:25:43 +0900 Subject: [PATCH 2/3] Fix illegible highlighting of Error Solution: Save Error highlight value and turn off temporarily, and restore after EasyMotion close #78 Thanks @LFDM --- autoload/EasyMotion.vim | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index aac915b..909e2a7 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -364,6 +364,34 @@ function! s:RestoreValue() "{{{ call s:VarReset('&virtualedit') call s:VarReset('&foldmethod') endfunction "}}} +function! s:turn_on_hl_error() "{{{ + if exists("s:old_hl_error") + execute "highlight Error " . s:old_hl_error + unlet s:old_hl_error + endif +endfunction "}}} +function! s:turn_off_hl_error() "{{{ + if exists("s:old_hl_error") + return s:old_hl_error + endif + if hlexists("Error") + let save_verbose = &verbose + let &verbose = 0 + try + redir => cursor + silent highlight Error + redir END + finally + let &verbose = save_verbose + endtry + let hl = substitute(matchstr(cursor, 'xxx \zs.*'), '[ \t\n]\+\|cleared', ' ', 'g') + if !empty(substitute(hl, '\s', '', 'g')) + let s:old_hl_error = hl + endif + highlight Error NONE + return s:old_hl_error + endif +endfunction "}}} " -- Draw -------------------------------- function! s:SetLines(lines, key) " {{{ for [line_num, line] in a:lines @@ -1049,6 +1077,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive) " {{{ " -- Reset properties -------------------- {{{ " Save original value and set new value call s:SaveValue() + call s:turn_off_hl_error() " }}} " Setup searchpos args {{{ let search_direction = (a:direction >= 1 ? 'b' : '') @@ -1361,6 +1390,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive) " {{{ finally " -- Restore properties ------------------ {{{ call s:RestoreValue() + call s:turn_on_hl_error() call EasyMotion#reset() " }}} " -- Remove shading ---------------------- {{{ From 37e6297bc4b71751d6055ecc612f1dc38cd8197d Mon Sep 17 00:00:00 2001 From: haya14busa Date: Mon, 10 Feb 2014 20:32:10 +0900 Subject: [PATCH 3/3] Fix typo --- autoload/EasyMotion.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 909e2a7..3655d8e 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -3,7 +3,7 @@ " Author: Kim Silkebækken " haya14busa " Source: https://github.com/Lokaltog/vim-easymotion -" Last Change: 07 Feb 2014. +" Last Change: 10 Feb 2014. "============================================================================= " Saving 'cpoptions' {{{ scriptencoding utf-8 @@ -378,13 +378,13 @@ function! s:turn_off_hl_error() "{{{ let save_verbose = &verbose let &verbose = 0 try - redir => cursor + redir => error silent highlight Error redir END finally let &verbose = save_verbose endtry - let hl = substitute(matchstr(cursor, 'xxx \zs.*'), '[ \t\n]\+\|cleared', ' ', 'g') + let hl = substitute(matchstr(error, 'xxx \zs.*'), '[ \t\n]\+\|cleared', ' ', 'g') if !empty(substitute(hl, '\s', '', 'g')) let s:old_hl_error = hl endif