Skip to content

Commit

Permalink
Merge pull request #610 from kkoomen/feature/fix-undo-cursor-position…
Browse files Browse the repository at this point in the history
…-bug

Fix undo cursor position bug
  • Loading branch information
kkoomen authored Aug 13, 2023
2 parents 0b0bbc3 + f00f52b commit 8b0c8d3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/doge.vim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function! doge#run_parser() abort
let l:current_line = l:cursor_pos[1]

let l:tempfile = tempname()
keepjumps call execute('%!tee ' . l:tempfile, 'silent!')
keepjumps call writefile(getline(line('^'), line('$')), l:tempfile)

let l:args = [
\ '--filepath', l:tempfile,
Expand Down
32 changes: 32 additions & 0 deletions test/undo-cursor-pos.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ==============================================================================
# Make sure that pressing 'u' after generating a docblock doesn't jump to the
# top of the file.
#
# See https://github.com/kkoomen/vim-doge/issues/309
# ==============================================================================
Given javascript(function):
function foo() {
//
}

function bar() {
//
}

Do (trigger doge):
:call cursor(5,8)\<CR>
\<C-d>
u

Expect javascript (no changes):
function foo() {
//
}

function bar() {
//
}

Then (the cursor should be at the same pos as before generating the comment):
AssertEqual 5, line('.')
AssertEqual 8, col('.')

0 comments on commit 8b0c8d3

Please sign in to comment.