aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/drawscreen.c
diff options
context:
space:
mode:
authornwounkn <nwounkn@gmail.com>2023-10-26 08:44:28 +0500
committerGitHub <noreply@github.com>2023-10-26 11:44:28 +0800
commit9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545 (patch)
treebdd09d6fec50cd1b85680d53d6b9bb8f7d384288 /src/nvim/drawscreen.c
parentf2fc44550fbe5b7ebfedc2b155dc41e93f49aedb (diff)
downloadrneovim-9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545.tar.gz
rneovim-9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545.tar.bz2
rneovim-9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545.zip
fix(float): win_get_bordertext_col returning negative column number (#25752)
Problem: `win_get_bordertext_col` returns column < 1 for right or center aligned text, if its length is more than window width. Solution: Return max(resulting_column, 1)
Diffstat (limited to 'src/nvim/drawscreen.c')
-rw-r--r--src/nvim/drawscreen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index ca70c1f4ef..adbe0f473f 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -735,9 +735,9 @@ int win_get_bordertext_col(int total_col, int text_width, AlignTextPos align)
case kAlignLeft:
return 1;
case kAlignCenter:
- return (total_col - text_width) / 2 + 1;
+ return MAX((total_col - text_width) / 2 + 1, 1);
case kAlignRight:
- return total_col - text_width + 1;
+ return MAX(total_col - text_width + 1, 1);
}
UNREACHABLE;
}