api/window_set_cursor: make sure cursor line is visible.

Previously, the cursor could be left outside the visible range if window
is not the current window
This commit is contained in:
Björn Linse
2014-07-14 13:54:15 +02:00
parent 591391b9bc
commit b34705bf5f
2 changed files with 17 additions and 0 deletions

View File

@@ -34,6 +34,7 @@
#include "nvim/popupmnu.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/window.h"
typedef struct {
linenr_T lnum; /* line number */
@@ -314,6 +315,17 @@ void update_topline(void)
p_so = save_so;
}
/*
* Update win->w_topline to move the cursor onto the screen.
*/
void update_topline_win(win_T* win)
{
win_T *save_curwin;
switch_win(&save_curwin, NULL, win, NULL, true);
update_topline();
restore_win(save_curwin, NULL, true);
}
/*
* Return the scrolljump value to use for the current window.
* When 'scrolljump' is positive use it as-is.