Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set curswant in nvim_win_set_cursor #8613

Merged
merged 2 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/nvim/api/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err)
// When column is out of range silently correct it.
check_cursor_col_win(win);

// Make sure we stick in this column.
win->w_curswant = (colnr_T)col;

// make sure cursor is in visible range even if win != curwin
update_topline_win(win);

Expand Down
23 changes: 23 additions & 0 deletions test/functional/api/window_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ describe('api/win', function()
neq(win, curwin())
end)

it('remembers what column it wants to be in', function()
insert("first line")
feed('o<esc>')
insert("second line")

feed('gg')
wait() -- let nvim process the 'gg' command

-- cursor position is at beginning
local win = curwin()
eq({1, 0}, window('get_cursor', win))

-- move cursor to column 5
window('set_cursor', win, {1, 5})

-- move down a line
feed('j')
wait() -- let nvim process the 'j' command

-- cursor is still in column 5
eq({2, 5}, window('get_cursor', win))
end)

end)

describe('{get,set}_height', function()
Expand Down