Skip to content

Commit

Permalink
Fix visual mode highlighting. Ref #50
Browse files Browse the repository at this point in the history
  • Loading branch information
osyo-manga committed Aug 23, 2015
1 parent e1734a1 commit 0d99be7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
5 changes: 3 additions & 2 deletions autoload/over.vim
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ function! over#unsetup()
endfunction


function! over#command_line(prompt, input)
return over#command_line#start(a:prompt, a:input)
function! over#command_line(prompt, input, ...)
let context = get(a:, 1, {})
return over#command_line#start(a:prompt, a:input, context)
endfunction


Expand Down
19 changes: 12 additions & 7 deletions autoload/over/command_line.vim
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,22 @@ call s:main.connect(s:module)

let g:over#command_line#enable_Digraphs = get(g:, "over#command_line#enable_Digraphs", 1)

function! over#command_line#start(prompt, input)
function! over#command_line#start(prompt, input, ...)
let context = get(a:, 1, {})

if g:over#command_line#enable_Digraphs
\ && empty(over#command_line#get().get_module("Digraphs"))
call over#command_line#get().connect("Digraphs")
else
call over#command_line#get().disconnect("Digraphs")
endif

if get(context, "line1", 1) != get(context, "line2", 1)
call s:main.connect(s:hl_visualmode)
else
call s:main.disconnect("HighlightVisualMode")
endif

if exists("*strchars") && has("conceal")
call s:main.set_prompt(a:prompt)
let exit_code = s:main.start(a:input)
Expand Down Expand Up @@ -214,11 +222,11 @@ endfunction



let s:module = {
let s:hl_visualmode = {
\ "name" : "HighlightVisualMode"
\}

function! s:module.on_enter(...)
function! s:hl_visualmode.on_enter(...)
if &selection == "exclusive"
let pat = '\%''<\|\%>''<.*\%<''>'
else
Expand All @@ -229,14 +237,11 @@ function! s:module.on_enter(...)
endfunction


function! s:module.on_leave(...)
function! s:hl_visualmode.on_leave(...)
call s:Highlight.clear("visualmode")
endfunction


call s:main.connect(s:module)



let &cpo = s:save_cpo
unlet s:save_cpo
5 changes: 3 additions & 2 deletions plugin/over.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ command! -range -nargs=*
\ OverCommandLine
\ call over#command_line(
\ g:over_command_line_prompt,
\ <line1> != <line2> ? printf("'<,'>%s", <q-args>) : <q-args>
\)
\ <line1> != <line2> ? printf("'<,'>%s", <q-args>) : <q-args>,
\ { "line1" : <line1>, "line2" : <line2> }
\ )


function! s:key_mapping(lhs, rhs, noremap)
Expand Down

0 comments on commit 0d99be7

Please sign in to comment.