Skip to content
Browse files

Fix an off-by-one issue in sci_get_position_from_line()

Scintilla counts lines from 0 but TagManager from 1, so convert them.
  • Loading branch information...
1 parent d83bd40 commit 9d2dab8fcf4aa4d2b890724b44d483d273732b3c @b4n b4n committed Sep 17, 2012
Showing with 3 additions and 3 deletions.
  1. +1 −1 src/callbacks.c
  2. +2 −2 src/symbols.c
View
2 src/callbacks.c
@@ -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);
View
4 src/symbols.c
@@ -2117,15 +2117,15 @@ 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)
{
gchar *tmp;
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;
}
}

0 comments on commit 9d2dab8

Please sign in to comment.
Something went wrong with that request. Please try again.