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



commit f2b78d14017741831e6f4e273be2544e30eedc0d
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.

 plugins/todo/gbp-todo-panel.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/plugins/todo/gbp-todo-panel.c b/plugins/todo/gbp-todo-panel.c
index 456b697..a65b718 100644
--- a/plugins/todo/gbp-todo-panel.c
+++ b/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]