[anjuta/python-support: 24/28] python-support: More fixes on autocompletion



commit afe74e7b9e0aecddd11d509cf942614459ac896d
Author: Johannes Schmid <jhs gnome org>
Date:   Thu Aug 5 19:00:17 2010 +0200

    python-support: More fixes on autocompletion

 plugins/language-support-python/plugin.c        |    4 +-
 plugins/language-support-python/python-assist.c |   25 +++++++++++++++++-----
 2 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/plugins/language-support-python/plugin.c b/plugins/language-support-python/plugin.c
index 3824a4a..83e25c1 100644
--- a/plugins/language-support-python/plugin.c
+++ b/plugins/language-support-python/plugin.c
@@ -1049,8 +1049,8 @@ on_value_removed_current_editor (AnjutaPlugin *plugin, const gchar *name,
 		g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
 										  G_CALLBACK (on_editor_language_changed),
 										  plugin);
-	if (IANJUTA_IS_EDITOR(lang_plugin->current_editor))
-		uninstall_support (lang_plugin);
+
+	uninstall_support (lang_plugin);
 
 	g_free (lang_plugin->current_editor_filename);
 	lang_plugin->current_editor_filename = NULL;
diff --git a/plugins/language-support-python/python-assist.c b/plugins/language-support-python/python-assist.c
index b315076..3222b67 100644
--- a/plugins/language-support-python/python-assist.c
+++ b/plugins/language-support-python/python-assist.c
@@ -301,8 +301,16 @@ python_assist_update_autocomplete (PythonAssist *assist)
 		suggestions = g_list_prepend (suggestions, proposal);
 	}
 	suggestions = g_list_reverse (suggestions);
-	ianjuta_editor_assist_proposals (assist->priv->iassist, IANJUTA_PROVIDER(assist),
-	                                 suggestions, TRUE, NULL);
+	/* Hide is the only suggetions is exactly the typed word */
+	if (!(g_list_length (suggestions) == 1 && 
+	      g_str_equal (((PythonAssistTag*)(suggestions->data))->name, assist->priv->pre_word)))
+	{
+		ianjuta_editor_assist_proposals (assist->priv->iassist, IANJUTA_PROVIDER(assist),
+		                                 suggestions, TRUE, NULL);
+	}
+	else
+		ianjuta_editor_assist_proposals (assist->priv->iassist, IANJUTA_PROVIDER(assist),
+		                                 NULL, TRUE, NULL);		
 	g_list_foreach (suggestions, (GFunc) free_proposal, NULL);
 	g_list_free (suggestions);
 }
@@ -345,6 +353,7 @@ on_autocomplete_output (AnjutaLauncher *launcher,
 	PythonAssist* assist = PYTHON_ASSIST (user_data);
 	if (output_type == ANJUTA_LAUNCHER_OUTPUT_STDOUT)
 	{
+		printf ("chars from script: %s", chars);
 		if (assist->priv->rope_cache)
 		{
 			g_string_append (assist->priv->rope_cache, chars);
@@ -354,6 +363,10 @@ on_autocomplete_output (AnjutaLauncher *launcher,
 			assist->priv->rope_cache = g_string_new (chars);
 		}
 	}
+	if (output_type == ANJUTA_LAUNCHER_OUTPUT_STDERR)
+	{
+		g_warning ("Problem in python script: %s", chars);
+	}
 }
 
 static void
@@ -377,7 +390,7 @@ on_autocomplete_finished (AnjutaLauncher* launcher,
 		                             0, 0, &err);
 		if (err)
 		{
-			DEBUG_PRINT ("Error creating regex: %s", err->message);
+			g_warning ("Error creating regex: %s", err->message);
 			g_error_free (err);
 			return;
 		}
@@ -500,7 +513,6 @@ on_calltip_output (AnjutaLauncher *launcher,
                    gpointer user_data)
 {
 	PythonAssist* assist = PYTHON_ASSIST (user_data);
-	DEBUG_PRINT ("Calltip output: %s", chars);
 	if (output_type == ANJUTA_LAUNCHER_OUTPUT_STDOUT)
 	{
 		if (assist->priv->calltip_cache)
@@ -801,6 +813,7 @@ python_assist_populate (IAnjutaProvider* self, IAnjutaIterable* cursor, GError**
 	{
 		if (pre_word && g_str_has_prefix (pre_word, assist->priv->pre_word))
 		{
+			DEBUG_PRINT ("Continue autocomplete for %s", pre_word);
 			/* Great, we just continue the current completion */
 			if (assist->priv->start_iter)
 				g_object_unref (assist->priv->start_iter);
@@ -814,6 +827,7 @@ python_assist_populate (IAnjutaProvider* self, IAnjutaIterable* cursor, GError**
 	}
 	else
 	{
+		DEBUG_PRINT ("Cancelling autocomplete");
 		python_assist_destroy_completion_cache (assist);
 	}
 	dot = python_assist_dot (IANJUTA_EDITOR (assist->priv->iassist),
@@ -821,6 +835,7 @@ python_assist_populate (IAnjutaProvider* self, IAnjutaIterable* cursor, GError**
 	if (((pre_word && strlen (pre_word) >= 3) || dot) && 
 	    python_assist_create_word_completion_cache (assist, cursor))
 	{
+		DEBUG_PRINT ("New autocomplete for %s", pre_word);
 		if (assist->priv->start_iter)
 			g_object_unref (assist->priv->start_iter);
 		if (start_iter)
@@ -940,8 +955,6 @@ python_assist_uninstall (PythonAssist *assist)
 {
 	g_return_if_fail (assist->priv->iassist != NULL);
 
-	DEBUG_PRINT ("Python uninstall called\n");
-
 	ianjuta_editor_assist_remove (assist->priv->iassist, IANJUTA_PROVIDER(assist), NULL);
 
 	assist->priv->iassist = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]