A small fix for the bisect thing. When opening a new document at page 1, the
bisect algorithm does not understand that it must begin a new bisect, and does
not move from page 0 (the bisect struct is all initialized to 0's).

The attached patch initializes the bisect range to 0, numpages-1, so that the
first bisect always has range the entire document.

Also I attach a small patch regarding empty jumplists. sc_jumplist detects such
case with an assertion. I think it is better to use regular flow control, and
leave assertions for exceptional things that should never happen, like a NULL
zathura pointer.

Abdó.

>From 02f4e020cc1c1b2d66d5ad1b4ef784c0225bf39b Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.r...@gmail.com>
Date: Sun, 7 Jul 2013 01:18:52 +0200
Subject: [PATCH] Initialize bisect state when opening document

Otherwise, when opening a document at page 1, and no jumps are added,
bisect does not understand it has to initialize the bisect range, and
does not move from page 1.
---
 zathura.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/zathura.c b/zathura.c
index d4d638d..70fa5cc 100644
--- a/zathura.c
+++ b/zathura.c
@@ -654,6 +654,11 @@ document_open(zathura_t* zathura, const char* path, const char* password,
     zathura_document_set_adjust_mode(document, ZATHURA_ADJUST_NONE);
   }
 
+  /* initialize bisect state */
+  zathura->bisect.start = 0;
+  zathura->bisect.last_jump = zathura_document_get_current_page_number(document);
+  zathura->bisect.end = number_of_pages - 1;
+
   /* update statusbar */
   bool basename_only = false;
   girara_setting_get(zathura->ui.session, "statusbar-basename", &basename_only);
-- 
1.8.3.2

>From 863443d53327334733a26ce9035757e08deab93b Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.r...@gmail.com>
Date: Sun, 7 Jul 2013 01:00:50 +0200
Subject: [PATCH] don't use assertions to make sure jumplist is nonempty

g_return_val_if_fail assertions should be used for exceptional things,
lika a NULL zathura pointer, not normal program flow.
---
 shortcuts.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/shortcuts.c b/shortcuts.c
index 937a8cd..6606d60 100644
--- a/shortcuts.c
+++ b/shortcuts.c
@@ -722,7 +722,11 @@ sc_jumplist(girara_session_t* session, girara_argument_t* argument,
   zathura_t* zathura = session->global.data;
   g_return_val_if_fail(argument != NULL, false);
   g_return_val_if_fail(zathura->document != NULL, false);
-  g_return_val_if_fail(zathura->jumplist.size != 0, false);
+
+  /* if no jumps in the jumplist */
+  if (zathura->jumplist.size == 0) {
+    return;
+  }
 
   GtkAdjustment* hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
   GtkAdjustment* vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
-- 
1.8.3.2

_______________________________________________
zathura mailing list
zathura@lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura

Reply via email to