[geany/geany] 9d2dab: Fix an off-by-one issue in sci_get_position_from_line()

Colomban Wendling git-noreply at xxxxx
Mon Sep 17 18:22:52 UTC 2012


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Mon, 17 Sep 2012 18:22:52
Commit:      9d2dab8fcf4aa4d2b890724b44d483d273732b3c
             https://github.com/geany/geany/commit/9d2dab8fcf4aa4d2b890724b44d483d273732b3c

Log Message:
-----------
Fix an off-by-one issue in sci_get_position_from_line()

Scintilla counts lines from 0 but TagManager from 1, so convert them.


Modified Paths:
--------------
    src/callbacks.c
    src/symbols.c

Modified: src/callbacks.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1171,7 +1171,7 @@ G_MODULE_EXPORT void on_comments_function_activate(GtkMenuItem *menuitem, gpoint
 	/* symbols_get_current_function returns -1 on failure, so sci_get_position_from_line
 	 * returns the current position, so it should be safe */
 	line = symbols_get_current_function(doc, &cur_tag);
-	pos = sci_get_position_from_line(doc->editor->sci, line - 1);
+	pos = sci_get_position_from_line(doc->editor->sci, line);
 
 	text = templates_get_template_function(doc, cur_tag);
 


Modified: src/symbols.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -2117,7 +2117,7 @@ gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname)
 	if (tm_file != NULL && tm_file->tags_array != NULL &&
 		(! doc->changed || editor_prefs.autocompletion_update_freq > 0))
 	{
-		const TMTag *tag = (const TMTag*) tm_get_current_function(tm_file->tags_array, line);
+		const TMTag *tag = (const TMTag*) tm_get_current_function(tm_file->tags_array, line + 1);
 
 		if (tag != NULL)
 		{
@@ -2125,7 +2125,7 @@ gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname)
 			tmp = tag->atts.entry.scope;
 			cur_tag = tmp ? g_strconcat(tmp, "::", tag->name, NULL) : g_strdup(tag->name);
 			*tagname = cur_tag;
-			tag_line = tag->atts.entry.line;
+			tag_line = tag->atts.entry.line - 1;
 			return tag_line;
 		}
 	}


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list