From ae8ec99d5c64d9d29f11c4f0e622fff0ae0f1b5e Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 13 Jun 2022 00:14:35 +0200 Subject: [PATCH 1/7] fix scrollback redraw not updating linecount --- src/fe-text/textbuffer-commands.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fe-text/textbuffer-commands.c b/src/fe-text/textbuffer-commands.c index f30eab0e..6ed7c39c 100644 --- a/src/fe-text/textbuffer-commands.c +++ b/src/fe-text/textbuffer-commands.c @@ -393,6 +393,7 @@ static void cmd_scrollback_redraw(void) term_refresh_freeze(); textbuffer_view_reset_cache(gui->view); + textbuffer_view_resize(gui->view, gui->view->width, gui->view->height); gui_window_redraw(active_win); term_refresh_thaw(); } From 67aa2baf62d09da7c7d53fc0e52772af7d2430c2 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 13 Jun 2022 00:15:13 +0200 Subject: [PATCH 2/7] fix memory leak when updating single line --- src/fe-text/textbuffer-view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index 0c89f600..eb7db164 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -419,7 +419,7 @@ static void view_remove_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line, cache = g_hash_table_lookup(view->cache->line_cache, line); if (cache != NULL) { - g_free(cache); + line_cache_destroy(NULL, cache); g_hash_table_remove(view->cache->line_cache, line); } } From 04b914dcb09aab11f764d55079a939194ec010fc Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 13 Jun 2022 00:17:05 +0200 Subject: [PATCH 3/7] fix visible lines expiring from cache --- src/fe-text/textbuffer-view.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index eb7db164..a28df7b5 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -1494,12 +1494,18 @@ static int line_cache_check_remove(void *key, LINE_CACHE_REC *cache, static int sig_check_linecache(void) { GSList *tmp, *caches; - time_t now; + time_t now; - now = time(NULL); caches = NULL; + now = time(NULL); + caches = NULL; for (tmp = views; tmp != NULL; tmp = tmp->next) { TEXT_BUFFER_VIEW_REC *rec = tmp->data; + if (rec->window != NULL) { + /* keep visible lines mapped */ + view_get_lines_height(rec, rec->startline, rec->subline, NULL); + } + if (g_slist_find(caches, rec->cache) != NULL) continue; @@ -1509,7 +1515,7 @@ static int sig_check_linecache(void) &now); } - g_slist_free(caches); + g_slist_free(caches); return 1; } From 48edd6f5fa75b2394782f5c6d211a1e3018b4852 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 13 Jun 2022 00:45:58 +0200 Subject: [PATCH 4/7] fix recount of lines after window set --- src/fe-text/textbuffer-view.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index a28df7b5..561a1ea3 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -1464,8 +1464,10 @@ void textbuffer_view_set_window(TEXT_BUFFER_VIEW_REC *view, if (view->window != window) { view->window = window; - if (window != NULL) + if (window != NULL) { + textbuffer_view_resize(view, view->width, view->height); view->dirty = TRUE; + } } } From b028b8e19d3161f48c7c83a0d7e7b83e6fb5f029 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 13 Jun 2022 08:59:27 +0200 Subject: [PATCH 5/7] fix recount of lines after scroll --- src/fe-text/textbuffer-view.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index 561a1ea3..7d007e40 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -1023,13 +1023,17 @@ void textbuffer_view_clear(TEXT_BUFFER_VIEW_REC *view) /* Scroll the view up/down */ void textbuffer_view_scroll(TEXT_BUFFER_VIEW_REC *view, int lines) { - int count; + int count, ypos; - g_return_if_fail(view != NULL); + g_return_if_fail(view != NULL); + + count = view_scroll(view, &view->startline, &view->subline, lines, TRUE); + + ypos = view->ypos + (lines < 0 ? count : -count); + textbuffer_view_init_ypos(view); + if (ypos != view->ypos) + textbuffer_view_resize(view, view->width, view->height); - count = view_scroll(view, &view->startline, &view->subline, - lines, TRUE); - view->ypos += lines < 0 ? count : -count; view->bottom = view_is_bottom(view); if (view->bottom) view->more_text = FALSE; From 453e65bbfe0c3bec9b5bb56c53b306aa1628c09d Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 13 Jun 2022 00:48:07 +0200 Subject: [PATCH 6/7] misc cleanup --- src/fe-text/textbuffer-view.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index 7d007e40..ee474785 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -394,10 +394,9 @@ view_update_line_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) if (rec->count > 1) { for (pos = 0; lines != NULL; pos++) { - void *data = lines->data; + LINE_CACHE_SUB_REC *data = lines->data; - memcpy(&rec->lines[pos], data, - sizeof(LINE_CACHE_SUB_REC)); + memcpy(&rec->lines[pos], data, sizeof(LINE_CACHE_SUB_REC)); lines = g_slist_remove(lines, data); g_free(data); @@ -430,7 +429,7 @@ static void view_update_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line, view_remove_cache(view, line, update_counter); if (view->buffer->cur_line == line) - view->cache->last_linecount = view_get_linecount(view, line); + view_get_linecount(view, line); } void textbuffer_view_reset_cache(TEXT_BUFFER_VIEW_REC *view) @@ -459,6 +458,7 @@ static int view_line_draw(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line, unichar chr; int xpos, color, drawcount, first, need_move, need_clrtoeol, char_width; unsigned int fg24, bg24; + fg24 = bg24 = UINT_MAX; if (view->dirty) /* don't bother drawing anything - redraw is coming */ return 0; @@ -757,7 +757,6 @@ static void view_unregister_indent_func(TEXT_BUFFER_VIEW_REC *view, /* recreate cache so it won't contain references to the indent function */ textbuffer_view_reset_cache(view); - view->cache = textbuffer_cache_get(view->siblings, view->width); } void textbuffer_views_unregister_indent_func(INDENT_FUNC indent_func) @@ -1073,10 +1072,10 @@ LINE_CACHE_REC *textbuffer_view_get_line_cache(TEXT_BUFFER_VIEW_REC *view, cache = g_hash_table_lookup(view->cache->line_cache, line); if (cache == NULL) cache = view_update_line_cache(view, line); - else + else cache->last_access = time(NULL); - return cache; + return cache; } static void view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) @@ -1257,12 +1256,13 @@ static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line, view_bookmarks_check(view, line); if (view->buffer->cur_line == line) { - /* the last line is being removed */ + /* the last line is being removed */ LINE_REC *prevline; - prevline = view->buffer->first_line == line ? NULL : - textbuffer_line_last(view->buffer)->prev; - view->cache->last_linecount = prevline == NULL ? 0 : + prevline = view->buffer->first_line == line ? + NULL : + textbuffer_line_last(view->buffer)->prev; + if (prevline != NULL) view_get_linecount(view, prevline); } From 4dc3eb10481c96be09feec93a09194b146d3aceb Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 13 Jun 2022 01:51:03 +0200 Subject: [PATCH 7/7] update clang-format --- .github/workflows/clangformat.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clangformat.yml b/.github/workflows/clangformat.yml index 59beb928..9076edc2 100644 --- a/.github/workflows/clangformat.yml +++ b/.github/workflows/clangformat.yml @@ -2,10 +2,10 @@ on: [pull_request] name: clang-format jobs: check-clang-format: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: install clang-format - run: sudo apt install clang-format-11 + run: sudo apt install clang-format-14 - uses: actions/checkout@main - name: fetch target ref run: @@ -20,7 +20,7 @@ jobs: - name: run git-clang-format and Check if no changes are needed run: | - CLANG_FORMAT=clang-format-11 git-clang-format-11 --diff FETCH_HEAD HEAD | tee git-clang-format.diff + CLANG_FORMAT=clang-format-14 git-clang-format-14 --diff FETCH_HEAD HEAD | tee git-clang-format.diff cmp -s <(echo no modified files to format) git-clang-format.diff || cmp -s <(echo -n) git-clang-format.diff - uses: actions/upload-artifact@v1 if: failure()