[gnome-builder] todo: Fix off-by-one in line number conversion



commit f6b7dad39b4c3b1283927975c052d827f7587493
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 13 16:07:00 2017 -0700

    todo: Fix off-by-one in line number conversion
    
    When converting from the line number provided from our grep,
    we need to subtract 1 to get the line number that is useful to
    the GtkTextIter infrastructure.

 src/plugins/todo/gbp-todo-panel.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/todo/gbp-todo-panel.c b/src/plugins/todo/gbp-todo-panel.c
index e44efa1..d1546a0 100644
--- a/src/plugins/todo/gbp-todo-panel.c
+++ b/src/plugins/todo/gbp-todo-panel.c
@@ -134,9 +134,14 @@ gbp_todo_panel_row_activated (GbpTodoPanel      *self,
   uri = ide_uri_new_from_file (file);
 
   /* Set lineno info so that the editor can jump
-   * to the location of the TODO item.
+   * to the location of the TODO item. Our line number
+   * from the model is 1-based, and we need 0-based for
+   * our API to open files.
    */
   lineno = gbp_todo_item_get_lineno (item);
+  if (lineno > 0)
+    lineno--;
+
   fragment = g_strdup_printf ("L%u", lineno);
   ide_uri_set_fragment (uri, fragment);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]