aboutsummaryrefslogtreecommitdiff
path: root/vterm-module.c
diff options
context:
space:
mode:
authorjixiuf <jixiuf@qq.com>2020-02-05 13:23:55 +0800
committerjixiuf <jixiuf@qq.com>2020-02-05 23:17:35 +0800
commitb541640791204adb6ecacf073bfb8aabd907e39b (patch)
tree3e2bbaea68074fb72cd9c3bca13f969b9f1860a7 /vterm-module.c
parent9faebc93f7b21b01eedfe4ebd7e20b6f88dc0aeb (diff)
handle recenter when decreasing the font size using the Emacs command text-scale-decrease.
Diffstat (limited to 'vterm-module.c')
-rw-r--r--vterm-module.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/vterm-module.c b/vterm-module.c
index 623e255..f6c74fa 100644
--- a/vterm-module.c
+++ b/vterm-module.c
@@ -428,13 +428,24 @@ static void adjust_topline(Term *term, emacs_env *env) {
size_t offset = get_col_offset(term, pos.row, pos.col);
forward_char(env, env->make_integer(env, pos.col - offset));
+ bool following = term->height == 1 + pos.row;
+
emacs_value windows = get_buffer_window_list(env);
emacs_value swindow = selected_window(env);
int winnum = env->extract_integer(env, length(env, windows));
for (int i = 0; i < winnum; i++) {
emacs_value window = nth(env, i, windows);
if (eq(env, window, swindow)) {
- recenter(env, env->make_integer(env, pos.row - term->height));
+ int win_body_height =
+ env->extract_integer(env, window_body_height(env, window));
+
+ /* recenter:If ARG is negative, it counts up from the bottom of the
+ * window. (ARG should be less than the height of the window ) */
+ if (term->height - pos.row <= win_body_height) {
+ recenter(env, env->make_integer(env, pos.row - term->height));
+ } else {
+ recenter(env, env->make_integer(env, pos.row));
+ }
} else {
if (env->is_not_nil(env, window)) {
set_window_point(env, window, point(env));