Permalink
Browse files

characterwise narrowing was brocken by last commit, fixes #22

  • Loading branch information...
1 parent b3d05f4 commit 02ba492ba49c598434fe90120729b7fe201376a1 @chrisbra committed Dec 10, 2013
Showing with 8 additions and 6 deletions.
  1. +8 −6 autoload/nrrwrgn.vim
View
@@ -753,8 +753,9 @@ fun! nrrwrgn#NrrwRgnDoPrepare(...) "{{{1
endfun
fun! nrrwrgn#NrrwRgn(mode, ...) range "{{{1
+ let visual = !empty(a:mode)
" a:mode is set when using visual mode
- if (a:mode)
+ if visual
" This beeps, when called from command mode
" e.g. by using :NRV, so using :sil!
" else exiting visual mode
@@ -765,7 +766,7 @@ fun! nrrwrgn#NrrwRgn(mode, ...) range "{{{1
let s:o_s = @/
set lz
call <sid>Init()
- if (a:mode)
+ if visual
let s:nrrw_rgn_lines[s:instn].vmode=a:mode
endif
" Protect the original buffer,
@@ -775,7 +776,7 @@ fun! nrrwrgn#NrrwRgn(mode, ...) range "{{{1
let _opts = <sid>SaveRestoreRegister([])
call <sid>CheckProtected()
- if (a:mode)
+ if visual
let [ s:nrrw_rgn_lines[s:instn].start,
\s:nrrw_rgn_lines[s:instn].end ] = <sid>RetVisRegionPos()
norm! gv"ay
@@ -785,8 +786,9 @@ fun! nrrwrgn#NrrwRgn(mode, ...) range "{{{1
" remove trailing "\n"
let @a=substitute(@a, '\n$', '', '')
endif
+ let a = split(@a, "\n")
- if a:mode == '' && <sid>CheckRectangularRegion(@a)
+ if visual && a:mode ==# '' && <sid>CheckRectangularRegion(@a)
" Rectangular selection
let s:nrrw_rgn_lines[s:instn].blockmode = 1
else
@@ -817,7 +819,7 @@ fun! nrrwrgn#NrrwRgn(mode, ...) range "{{{1
noa wincmd p
let s:nrrw_rgn_lines[s:instn].winnr = winnr()
" Set highlighting in original window
- if a:mode
+ if visual
call <sid>AddMatches(<sid>GeneratePattern(
\s:nrrw_rgn_lines[s:instn].start[1:2],
\s:nrrw_rgn_lines[s:instn].end[1:2],
@@ -835,7 +837,7 @@ fun! nrrwrgn#NrrwRgn(mode, ...) range "{{{1
endif
let b:orig_buf = orig_buf
let s:nrrw_rgn_lines[s:instn].orig_buf = orig_buf
- call setline(1, a:mode ? @a : a)
+ call setline(1, a)
let b:nrrw_instn = s:instn
setl nomod
call <sid>SetupBufLocalCommands()

0 comments on commit 02ba492

Please sign in to comment.