Skip to content

Commit

Permalink
fix(terminal): use coladvance() to calculate buffer cursor position
Browse files Browse the repository at this point in the history
  • Loading branch information
zeertzjq committed Dec 8, 2021
1 parent be768be commit 2784a5d
Show file tree
Hide file tree
Showing 3 changed files with 707 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/nvim/cursor.c
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/nvim/terminal.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 2784a5d

Please sign in to comment.