aboutsummaryrefslogtreecommitdiff
path: root/view.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-11-09 17:35:16 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-11-09 17:35:16 +0100
commit6a45bbc048ab78f021e0dffbe27bbc6ffce50e22 (patch)
treef2f74700e0b32d11c4860ca163746a106e1750ea /view.c
parent01bf9576d2e777810f56c17d4787fd035f4f5266 (diff)
downloadvis-6a45bbc048ab78f021e0dffbe27bbc6ffce50e22.tar.gz
vis-6a45bbc048ab78f021e0dffbe27bbc6ffce50e22.tar.xz
view: correctly redraw window content
If a change occured on the very first shown character, it was not properly reflected in the view.
Diffstat (limited to 'view.c')
-rw-r--r--view.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/view.c b/view.c
index 542a9e1..f984bfb 100644
--- a/view.c
+++ b/view.c
@@ -1105,11 +1105,14 @@ void view_cursors_to(Cursor *c, size_t pos) {
view->start = pos;
view_viewport_up(view, view->height / 2);
} else {
+ /* make sure we redraw changes to the very first character of the window */
+ if (view->start == pos)
+ view->start_last = 0;
/* set the start of the viewable region to the start of the line on which
* the cursor should be placed. if this line requires more space than
* available in the view then simply start displaying text at the new
* cursor position */
- for (int i = 0; i < 2 && (pos < view->start || pos > view->end); i++) {
+ for (int i = 0; i < 2 && (pos <= view->start || pos > view->end); i++) {
view->start = i == 0 ? text_line_begin(view->text, pos) : pos;
view_draw(view);
}