[geany/geany] 4bc5f4: Popup scope autocompletion dialog in more cases

Jiří Techet git-noreply at xxxxx
Thu Feb 11 14:35:55 UTC 2016


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sun, 10 Jan 2016 11:36:08 UTC
Commit:      4bc5f4a7e482d577cdbff9badf422479cb19714b
             https://github.com/geany/geany/commit/4bc5f4a7e482d577cdbff9badf422479cb19714b

Log Message:
-----------
Popup scope autocompletion dialog in more cases

* for PHP and Rust scope separator ::
* when there's more than one whitespace between the identifier and operator


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

Modified: src/editor.c
16 lines changed, 11 insertions(+), 5 deletions(-)
===================================================================
@@ -657,7 +657,9 @@ static gboolean match_last_chars(ScintillaObject *sci, gint pos, const gchar *st
 	gchar *buf;
 
 	g_return_val_if_fail(len < 100, FALSE);
-	g_return_val_if_fail((gint)len <= pos, FALSE);
+
+	if ((gint)len > pos)
+		return FALSE;
 
 	buf = g_alloca(len + 1);
 	sci_get_text_range(sci, pos - len, pos, buf);
@@ -706,11 +708,15 @@ static void autocomplete_scope(GeanyEditor *editor)
 	GeanyFiletype *ft = editor->document->file_type;
 	GPtrArray *tags;
 
-	if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP)
+	if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP ||
+		ft->id == GEANY_FILETYPES_PHP || ft->id == GEANY_FILETYPES_RUST)
 	{
-		if (pos >= 2 && (match_last_chars(sci, pos, "->") || match_last_chars(sci, pos, "::")))
+		if (match_last_chars(sci, pos, "::"))
+			pos--;
+		else if ((ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP) &&
+				 match_last_chars(sci, pos, "->"))
 			pos--;
-		else if (ft->id == GEANY_FILETYPES_CPP && pos >= 3 && match_last_chars(sci, pos, "->*"))
+		else if (ft->id == GEANY_FILETYPES_CPP && match_last_chars(sci, pos, "->*"))
 			pos-=2;
 		else if (typed != '.')
 			return;
@@ -719,7 +725,7 @@ static void autocomplete_scope(GeanyEditor *editor)
 		return;
 
 	/* allow for a space between word and operator */
-	if (isspace(sci_get_char_at(sci, pos - 2)))
+	while (pos >= 2 && isspace(sci_get_char_at(sci, pos - 2)))
 		pos--;
 	name = editor_get_word_at_pos(editor, pos - 1, NULL);
 	if (!name)



--------------
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