Fix indenting a snippet when there is whitespace after the
snippet key name. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4811 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
664333b8c8
commit
18a7e2ef08
@ -3,6 +3,9 @@
|
|||||||
* src/editor.c:
|
* src/editor.c:
|
||||||
Refactor snippets_complete_constructs().
|
Refactor snippets_complete_constructs().
|
||||||
Remove an unnecessary TODO.
|
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>
|
2010-04-07 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||||
|
|||||||
16
src/editor.c
16
src/editor.c
@ -103,6 +103,7 @@ static void close_block(GeanyEditor *editor, gint pos);
|
|||||||
static void editor_highlight_braces(GeanyEditor *editor, gint cur_pos);
|
static void editor_highlight_braces(GeanyEditor *editor, gint cur_pos);
|
||||||
static void read_current_word(GeanyEditor *editor, gint pos, gchar *word, size_t wordlen,
|
static void read_current_word(GeanyEditor *editor, gint pos, gchar *word, size_t wordlen,
|
||||||
const gchar *wc, gboolean stem);
|
const gchar *wc, gboolean stem);
|
||||||
|
static gsize count_indent_size(GeanyEditor *editor, const gchar *base_indent);
|
||||||
|
|
||||||
|
|
||||||
void editor_snippets_free(void)
|
void editor_snippets_free(void)
|
||||||
@ -2123,6 +2124,7 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint inser
|
|||||||
|
|
||||||
g_return_if_fail(text);
|
g_return_if_fail(text);
|
||||||
g_return_if_fail(editor != NULL);
|
g_return_if_fail(editor != NULL);
|
||||||
|
g_return_if_fail(insert_pos >= 0);
|
||||||
|
|
||||||
buf = g_string_new(text);
|
buf = g_string_new(text);
|
||||||
|
|
||||||
@ -2132,7 +2134,15 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint inser
|
|||||||
/* Add line indents (in spaces) */
|
/* Add line indents (in spaces) */
|
||||||
|
|
||||||
if (newline_indent_size == -1)
|
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)
|
if (newline_indent_size > 0)
|
||||||
{
|
{
|
||||||
@ -2366,7 +2376,6 @@ static gboolean at_eol(ScintillaObject *sci, gint pos)
|
|||||||
gboolean editor_complete_snippet(GeanyEditor *editor, gint pos)
|
gboolean editor_complete_snippet(GeanyEditor *editor, gint pos)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
gint lexer, style;
|
|
||||||
const gchar *wc;
|
const gchar *wc;
|
||||||
const gchar *word;
|
const gchar *word;
|
||||||
ScintillaObject *sci;
|
ScintillaObject *sci;
|
||||||
@ -2382,9 +2391,6 @@ gboolean editor_complete_snippet(GeanyEditor *editor, gint pos)
|
|||||||
! editor_prefs.complete_snippets_whilst_editing && ! at_eol(sci, pos))
|
! editor_prefs.complete_snippets_whilst_editing && ! at_eol(sci, pos))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
lexer = sci_get_lexer(sci);
|
|
||||||
style = sci_get_style_at(sci, pos - 2);
|
|
||||||
|
|
||||||
wc = snippets_find_completion_by_name("Special", "wordchars");
|
wc = snippets_find_completion_by_name("Special", "wordchars");
|
||||||
word = editor_read_word_stem(editor, pos, wc);
|
word = editor_read_word_stem(editor, pos, wc);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user