SF.net SVN: geany:[4811] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Thu Apr 8 16:26:36 UTC 2010
Revision: 4811
http://geany.svn.sourceforge.net/geany/?rev=4811&view=rev
Author: ntrel
Date: 2010-04-08 16:26:36 +0000 (Thu, 08 Apr 2010)
Log Message:
-----------
Fix indenting a snippet when there is whitespace after the
snippet key name.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-04-08 15:56:08 UTC (rev 4810)
+++ trunk/ChangeLog 2010-04-08 16:26:36 UTC (rev 4811)
@@ -3,6 +3,9 @@
* src/editor.c:
Refactor snippets_complete_constructs().
Remove an unnecessary TODO.
+ * src/editor.c:
+ Fix indenting a snippet when there is whitespace after the
+ snippet key name.
2010-04-07 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2010-04-08 15:56:08 UTC (rev 4810)
+++ trunk/src/editor.c 2010-04-08 16:26:36 UTC (rev 4811)
@@ -103,6 +103,7 @@
static void editor_highlight_braces(GeanyEditor *editor, gint cur_pos);
static void read_current_word(GeanyEditor *editor, gint pos, gchar *word, size_t wordlen,
const gchar *wc, gboolean stem);
+static gsize count_indent_size(GeanyEditor *editor, const gchar *base_indent);
void editor_snippets_free(void)
@@ -2123,6 +2124,7 @@
g_return_if_fail(text);
g_return_if_fail(editor != NULL);
+ g_return_if_fail(insert_pos >= 0);
buf = g_string_new(text);
@@ -2132,7 +2134,15 @@
/* Add line indents (in spaces) */
if (newline_indent_size == -1)
- newline_indent_size = sci_get_line_indentation(sci, line_start);
+ {
+ /* 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 = insert_pos - sci_get_position_from_line(sci, line_start);
+ tmp[idx] = '\0';
+ newline_indent_size = count_indent_size(editor, tmp);
+ g_free(tmp);
+ }
if (newline_indent_size > 0)
{
@@ -2366,7 +2376,6 @@
gboolean editor_complete_snippet(GeanyEditor *editor, gint pos)
{
gboolean result = FALSE;
- gint lexer, style;
const gchar *wc;
const gchar *word;
ScintillaObject *sci;
@@ -2382,9 +2391,6 @@
! editor_prefs.complete_snippets_whilst_editing && ! at_eol(sci, pos))
return FALSE;
- lexer = sci_get_lexer(sci);
- style = sci_get_style_at(sci, pos - 2);
-
wc = snippets_find_completion_by_name("Special", "wordchars");
word = editor_read_word_stem(editor, pos, wc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list