[gnome-builder] sourceview: handle large overscroll values gracefully
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] sourceview: handle large overscroll values gracefully
- Date: Tue, 26 Mar 2019 02:30:07 +0000 (UTC)
commit 916f86e4fb38354871497d75b71e625125be813f
Author: Christian Hergert <chergert redhat com>
Date: Mon Mar 25 19:27:20 2019 -0700
sourceview: handle large overscroll values gracefully
This tries to handle large overscroll values a bit more
gracefully and fallback to showing at least one line.
Related #643
src/libide/sourceview/ide-source-view.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index bbb6c4b2e..3beeefb62 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -3801,18 +3801,31 @@ ide_source_view_set_overscroll_num_lines (IdeSourceView *self,
gint num_lines)
{
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
- gint height = gtk_widget_get_allocated_height (GTK_WIDGET (self));
+ gint height;
gint new_margin;
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
priv->overscroll_num_lines = num_lines;
+
+ /* Do nothing if there is no height yet */
+ if (!(height = gtk_widget_get_allocated_height (GTK_WIDGET (self))))
+ return;
+
new_margin = priv->overscroll_num_lines * priv->cached_char_height;
if (new_margin < 0)
- new_margin = height + new_margin;
+ {
+ new_margin = height + new_margin;
+ if (new_margin < 0)
+ new_margin = height - priv->cached_char_height;
+ }
new_margin = CLAMP (new_margin, 0, height - priv->cached_char_height);
- g_object_set (self, "bottom-margin", new_margin, NULL);
+ g_object_set (self,
+ "bottom-margin", new_margin,
+ NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]