Merge pull request #16418 from zeertzjq/terminal-coladvance

fix(terminal): use coladvance() to calculate buffer cursor position
This commit is contained in:
James McCoy
2021-12-08 21:17:18 -05:00
committed by GitHub
3 changed files with 707 additions and 3 deletions

View File

@@ -108,6 +108,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
int head = 0;
one_more = (State & INSERT)
|| (State & TERM_FOCUS)
|| restart_edit != NUL
|| (VIsual_active && *p_sel != 'o')
|| ((ve_flags & VE_ONEMORE) && wcol < MAXCOL);

View File

@@ -46,6 +46,7 @@
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"
#include "nvim/event/loop.h"
#include "nvim/event/time.h"
@@ -464,9 +465,7 @@ static void terminal_check_cursor(void)
row_to_linenr(term, term->cursor.row));
// Nudge cursor when returning to normal-mode.
int off = is_focused(term) ? 0 : (curwin->w_p_rl ? 1 : -1);
curwin->w_cursor.col = MAX(0, term->cursor.col + win_col_off(curwin) + off);
curwin->w_cursor.coladd = 0;
mb_check_adjust_col(curwin);
coladvance(MAX(0, term->cursor.col + off));
}
// Function executed before each iteration of terminal mode.