aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/cursor.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-03-09 14:57:57 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-03-09 14:57:57 -0700
commitc324271b99eee4c621463f368914d57cd729bd9c (patch)
tree5d979d333a2d5f9c080991d5482fd5916f8579c6 /src/nvim/cursor.c
parent931bffbda3668ddc609fc1da8f9eb576b170aa52 (diff)
parentade1b12f49c3b3914c74847d791eb90ea90b56b7 (diff)
downloadrneovim-c324271b99eee4c621463f368914d57cd729bd9c.tar.gz
rneovim-c324271b99eee4c621463f368914d57cd729bd9c.tar.bz2
rneovim-c324271b99eee4c621463f368914d57cd729bd9c.zip
Merge remote-tracking branch 'upstream/master' into userreg
Diffstat (limited to 'src/nvim/cursor.c')
-rw-r--r--src/nvim/cursor.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index 1110fe1e64..e93e658f1e 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -11,9 +11,9 @@
#include "nvim/drawscreen.h"
#include "nvim/fold.h"
#include "nvim/globals.h"
-#include "nvim/macros_defs.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
+#include "nvim/mbyte_defs.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/move.h"
@@ -22,6 +22,8 @@
#include "nvim/plines.h"
#include "nvim/pos_defs.h"
#include "nvim/state.h"
+#include "nvim/state_defs.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -140,17 +142,18 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
}
}
- chartabsize_T cts;
- init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line);
- while (cts.cts_vcol <= wcol && *cts.cts_ptr != NUL) {
- // Count a tab for what it's worth (if list mode not on)
- csize = win_lbr_chartabsize(&cts, &head);
- MB_PTR_ADV(cts.cts_ptr);
- cts.cts_vcol += csize;
+ CharsizeArg csarg;
+ CSType cstype = init_charsize_arg(&csarg, curwin, pos->lnum, line);
+ StrCharInfo ci = utf_ptr2StrCharInfo(line);
+ col = 0;
+ while (col <= wcol && *ci.ptr != NUL) {
+ CharSize cs = win_charsize(cstype, col, ci.ptr, ci.chr.value, &csarg);
+ csize = cs.width;
+ head = cs.head;
+ col += cs.width;
+ ci = utfc_next(ci);
}
- col = cts.cts_vcol;
- idx = (int)(cts.cts_ptr - line);
- clear_chartabsize_arg(&cts);
+ idx = (int)(ci.ptr - line);
// Handle all the special cases. The virtual_active() check
// is needed to ensure that a virtual position off the end of
@@ -291,7 +294,7 @@ linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum)
// Loop until we reach to_line, skipping folds.
for (; from_line < to_line; from_line++, retval++) {
// If from_line is in a fold, set it to the last line of that fold.
- (void)hasFoldingWin(wp, from_line, NULL, &from_line, true, NULL);
+ hasFoldingWin(wp, from_line, NULL, &from_line, true, NULL);
}
// If to_line is in a closed fold, the line count is off by +1. Correct it.