[geany/geany] 18d524: editor: fix incorrect variable reference

Thomas Martitz git-noreply at xxxxx
Wed Jul 26 20:39:02 UTC 2017


Branch:      refs/heads/master
Author:      Thomas Martitz <kugel at rockbox.org>
Committer:   Thomas Martitz <kugel at rockbox.org>
Date:        Wed, 26 Jul 2017 20:39:02 UTC
Commit:      18d524525df6612a8ab7fd690aa99d815c59f80d
             https://github.com/geany/geany/commit/18d524525df6612a8ab7fd690aa99d815c59f80d

Log Message:
-----------
editor: fix incorrect variable reference

The variable used for setting the cursor isn't used anymore and
was used uninitialized. It's simply deleted now and the correct var is used.

This was only a problem if editor_insert_text_block() was used directly,
the snippet code path doesn't reach to it.


Modified Paths:
--------------
    src/editor.c

Modified: src/editor.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -2458,7 +2458,6 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint inser
 	gint line_start = sci_get_line_from_position(sci, insert_pos);
 	GString *buf;
 	const gchar *eol = editor_get_eol_char(editor);
-	gint idx;
 	GSList *jump_locs, *item;
 
 	g_return_if_fail(text);
@@ -2475,6 +2474,7 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint inser
 		/* count indent size up to insert_pos instead of asking sci
 		 * because there may be spaces after it */
 		gchar *tmp = sci_get_line(sci, line_start);
+		gint idx;
 
 		idx = insert_pos - sci_get_position_from_line(sci, line_start);
 		tmp[idx] = '\0';
@@ -2516,7 +2516,7 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint inser
 
 	/* Set cursor to the requested index, or by default to after the snippet */
 	if (cursor_index >= 0)
-		sci_set_current_position(sci, insert_pos + idx, FALSE);
+		sci_set_current_position(sci, insert_pos + cursor_index, FALSE);
 	else if (jump_locs == NULL)
 		sci_set_current_position(sci, insert_pos + buf->len, FALSE);
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list