Skip to content

Commit

Permalink
fix remote back jump repositioning when characters were deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfeld committed Mar 10, 2013
1 parent f5cc5f5 commit 795455e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## Known issues
* Remote back jump needs to account for the characters deleted when repositioning.
* Shorthand customization of keys not implemented yet.

## NEXT
Expand Down
9 changes: 7 additions & 2 deletions plugin/seek.vim
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function! s:seekJumpRemote(textobj)
let pos = l:cursor[2]
let seek = s:findTargetFwd(l:pos, v:count1)

let cmd = "execute 'call cursor(".l:cursor[1].", ".l:pos.")'"
let cmd = "execute 'call cursor(" . l:cursor[1]. ", " . l:pos . ")'"
call s:registerCommand('CursorMoved', cmd, 'remoteJump')

if l:seek != -1
Expand All @@ -199,7 +199,12 @@ function! s:seekBackJumpRemote(textobj)
let pos = l:cursor[2]
let seek = s:findTargetBwd(l:pos, v:count1)

let cmd = "execute 'call cursor(".l:cursor[1].", ".l:pos.")'"
" the remote back jump needs special treatment in repositioning the cursor,
" to account for possible characters deleted; we do this by diffing the line
" length before and after i.e. originalPos - (beforeLen - afterLen)
let before = len(getline('.'))
let cmd = "execute 'call cursor(" . l:cursor[1] . ", "
\ . (l:pos - l:before) . " + len(getline(\".\")))'"
call s:registerCommand('CursorMoved', cmd, 'remoteJump')

if l:seek != -1
Expand Down

0 comments on commit 795455e

Please sign in to comment.