From dceea37d0ee89d807b15e08e54edfdfe919a815d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 6 Jun 2017 12:21:31 -0400 Subject: [PATCH] renamed helper function for checking if line number resyncing is needed --- lib/view.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/view.c b/lib/view.c index 9a8daef..28574cb 100644 --- a/lib/view.c +++ b/lib/view.c @@ -22,6 +22,7 @@ static unsigned scroll_up(View* view); static unsigned scroll_dn(View* view); static void sync_center(View* view, size_t csr); static size_t getoffset(View* view, size_t row, size_t col); +static void sync_line_numbers(View* view); void view_init(View* view, char* file, void (*errfn)(char*)) { if (view->nrows) { @@ -193,20 +194,11 @@ bool view_findstr(View* view, int dir, char* str) { return found; } -static void update_lines(View* view) { - if (!view->nrows || - view->selection.beg <= view->rows[0]->off || - view->selection.end <= view->rows[0]->off) - view->sync_lines = true; -} - void view_insert(View* view, bool indent, Rune rune) { /* ignore non-printable control characters */ if (!isspace(rune) && rune < 0x20) return; - - update_lines(view); - + sync_line_numbers(view); if (num_selected(view->selection)) { Sel sel = view->selection; selswap(&sel); @@ -218,8 +210,7 @@ void view_insert(View* view, bool indent, Rune rune) { } void view_delete(View* view, int dir, bool byword) { - update_lines(view); - + sync_line_numbers(view); Sel* sel = &(view->selection); if (sel->beg == sel->end) (byword ? view_byword : view_byrune)(view, dir, true); @@ -660,3 +651,10 @@ static size_t getoffset(View* view, size_t row, size_t col) { return buf_end(&(view->buffer)); return pos; } + +static void sync_line_numbers(View* view) { + if (!view->nrows || + view->selection.beg <= view->rows[0]->off || + view->selection.end <= view->rows[0]->off) + view->sync_lines = true; +} -- 2.51.0