[gnome-builder] clang-completion: ignore clang completion priority
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] clang-completion: ignore clang completion priority
- Date: Mon, 7 Nov 2016 21:05:03 +0000 (UTC)
commit 382c607f0474e133915cd5f3246f1a3a98d5675d
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 7 13:02:34 2016 -0800
clang-completion: ignore clang completion priority
The value we get from clang is not very useful for completions because it
is only valid for the initial completion set. Once the user starts typing
additional text, the priority is invalid.
As clang suggests that we cache the results and perform refiltering client
side, we might as well just use our own scoring/priority engine from the
get-go.
plugins/clang/ide-clang-completion-item.c | 4 ----
plugins/clang/ide-clang-completion-provider.c | 13 +++++++++++--
2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/plugins/clang/ide-clang-completion-item.c b/plugins/clang/ide-clang-completion-item.c
index bef0deb..5a18b9c 100644
--- a/plugins/clang/ide-clang-completion-item.c
+++ b/plugins/clang/ide-clang-completion-item.c
@@ -563,14 +563,10 @@ ide_clang_completion_item_new (IdeRefPtr *results,
guint index)
{
IdeClangCompletionItem *ret;
- CXCompletionResult *result;
ret = g_object_new (IDE_TYPE_CLANG_COMPLETION_ITEM, NULL);
ret->results = ide_ref_ptr_ref (results);
ret->index = index;
- result = ide_clang_completion_item_get_result (ret);
- ret->priority = clang_getCompletionPriority (result->CompletionString);
-
return ret;
}
diff --git a/plugins/clang/ide-clang-completion-provider.c b/plugins/clang/ide-clang-completion-provider.c
index dcb9a16..34cf76e 100644
--- a/plugins/clang/ide-clang-completion-provider.c
+++ b/plugins/clang/ide-clang-completion-provider.c
@@ -321,7 +321,7 @@ ide_clang_completion_provider_refilter (IdeClangCompletionProvider *self,
if ((self->last_query != NULL) && g_str_has_prefix (query, self->last_query))
ide_clang_completion_provider_update_links (self, results);
- lower = g_utf8_strdown (query, -1);
+ lower = g_utf8_casefold (query, -1);
if (!g_str_is_ascii (lower))
{
@@ -332,8 +332,12 @@ ide_clang_completion_provider_refilter (IdeClangCompletionProvider *self,
for (GList *iter = self->head; iter; iter = iter->next)
{
IdeClangCompletionItem *item = iter->data;
+ const gchar *typed_text;
+ guint priority;
- if (!ide_clang_completion_item_match (item, lower))
+ typed_text = ide_clang_completion_item_get_typed_text (item);
+
+ if (!ide_completion_item_fuzzy_match (typed_text, lower, &priority))
{
if (iter->prev != NULL)
iter->prev->next = iter->next;
@@ -342,7 +346,12 @@ ide_clang_completion_provider_refilter (IdeClangCompletionProvider *self,
if (iter->next != NULL)
iter->next->prev = iter->prev;
+
+ continue;
}
+
+ /* Save the generated priority for further sorting */
+ item->priority = priority;
}
g_free (self->last_query);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]