From c0dab13571bc79d2171fec1d4f507c5560f4d881 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 10 Feb 2021 11:26:42 +0200 Subject: Window: Keep scroll position when resizing vertically Fixed broken logic. IssueID #138 --- src/ui/documentwidget.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index b9aa551f..e35892cf 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -1533,11 +1533,14 @@ static const int homeRowKeys_[] = { static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) { iWidget *w = as_Widget(d); if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "font.changed")) { - const iBool isHorizontalOnly = - argLabel_Command(cmd, "horiz") != 0 && !argLabel_Command(cmd, "vert"); + const iBool isVerticalOnly = + !argLabel_Command(cmd, "horiz") && argLabel_Command(cmd, "vert"); /* Alt/Option key may be involved in window size changes. */ iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iFalse); - if (isHorizontalOnly) { + if (isVerticalOnly) { + scroll_DocumentWidget_(d, 0); /* prevent overscroll */ + } + else { const iGmRun *mid = middleRun_DocumentWidget_(d); const char *midLoc = (mid ? mid->text.start : NULL); setWidth_GmDocument(d->doc, documentWidth_DocumentWidget_(d)); @@ -1549,9 +1552,6 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) } } } - else { - scroll_DocumentWidget_(d, 0); /* prevent overscroll */ - } updateSideIconBuf_DocumentWidget_(d); updateOutline_DocumentWidget_(d); invalidate_DocumentWidget_(d); -- cgit v1.2.3