From 982f608eb1dd3ad86c5dfec300ba878de32b357c Mon Sep 17 00:00:00 2001 From: Mike Lowis Date: Wed, 5 Oct 2016 09:00:08 -0400 Subject: [PATCH] fixed tab handling for locating cursor coordinates --- screen.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/screen.c b/screen.c index c7843b9..9035ac6 100644 --- a/screen.c +++ b/screen.c @@ -134,6 +134,7 @@ static void sync_view(Buf* buf, unsigned csr) { } void screen_update(Buf* buf, unsigned csr, unsigned* csrx, unsigned* csry) { + /* scroll the view and reflow the screen lines */ sync_view(buf, csr); if (buf->insert_mode) screen_reflow(buf); @@ -142,8 +143,15 @@ void screen_update(Buf* buf, unsigned csr, unsigned* csrx, unsigned* csry) { unsigned start = Rows[y]->off; unsigned end = Rows[y]->off + Rows[y]->rlen - 1; if (start <= csr && csr <= end) { - *csry = y; - *csrx = csr - start; + unsigned pos = start; + for (unsigned x = 0; x < NumCols;) { + if (pos == csr) { + *csry = y, *csrx = x; + break; + } + if (buf_get(buf,pos++) == '\t') + x += (TabWidth - (x % TabWidth)); + } break; } } -- 2.49.0