diff options
| author | jixiufeng <jixiufeng@luojilab.com> | 2018-11-28 00:37:56 +0800 |
|---|---|---|
| committer | jixiufeng <jixiufeng@luojilab.com> | 2018-12-01 00:45:55 +0800 |
| commit | c20f3729731cea6bc5ee8af9d05d26bdd9fbb23d (patch) | |
| tree | b0689b6d6e8cb6cb3173388f3a89ef6cb166c922 | |
| parent | c90f5b255c77190f6c3f2ee0ab7fbea062d7aae4 (diff) | |
fix window resize
| -rw-r--r-- | vterm-module.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/vterm-module.c b/vterm-module.c index 7c93fa7..7a39aff 100644 --- a/vterm-module.c +++ b/vterm-module.c @@ -197,10 +197,12 @@ static void refresh_screen(Term *term, emacs_env *env) { int height; int width; + // Term height may have decreased before `invalid_end` reflects it. + term->invalid_end = MIN(term->invalid_end, height); + if (term->invalid_end >= term->invalid_start) { vterm_get_size(term->vt, &height, &width); - // Term height may have decreased before `invalid_end` reflects it. int line_start = row_to_linenr(term, term->invalid_start); goto_line(env, line_start); delete_lines(env, line_start, term->invalid_end - term->invalid_start, @@ -212,8 +214,15 @@ static void refresh_screen(Term *term, emacs_env *env) { term->invalid_end = -1; } -static int term_resize(int rows, int cols, void *term) { - invalidate_terminal(term, 0, rows); +static int term_resize(int rows, int cols, void *user_data) { + /* can not use invalidate_terminal here */ + /* when the window heigh decreased, */ + /* the value of term->invalid_end can't bigger than window height */ + Term *term = (Term *)user_data; + term->invalid_start = 0; + term->invalid_end = rows; + invalidate_terminal(term,-1,-1); + return 1; } |
