[gnome-builder/gnome-builder-43] libide/lsp: setup default trigger character set
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-43] libide/lsp: setup default trigger character set
- Date: Thu, 22 Sep 2022 01:01:57 +0000 (UTC)
commit d8fdcaf886a69ae9f0eebf6675e84cb8df9aee86
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 21 18:01:44 2022 -0700
libide/lsp: setup default trigger character set
We might not get a value back from the peer for this, so assume that
period is always going to be wanted unless the peer gives us a character
set to work with.
Related #1800
src/libide/lsp/ide-lsp-completion-provider.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/src/libide/lsp/ide-lsp-completion-provider.c b/src/libide/lsp/ide-lsp-completion-provider.c
index 01845bc3d..012efb1e5 100644
--- a/src/libide/lsp/ide-lsp-completion-provider.c
+++ b/src/libide/lsp/ide-lsp-completion-provider.c
@@ -478,25 +478,20 @@ ide_lsp_completion_provider_is_trigger (GtkSourceCompletionProvider *provider,
const GtkTextIter *iter,
gunichar ch)
{
+ static const char * const default_trigger_chars[] = IDE_STRV_INIT (".");
IdeLspCompletionProvider *self = (IdeLspCompletionProvider *)provider;
IdeLspCompletionProviderPrivate *priv = ide_lsp_completion_provider_get_instance_private (self);
+ const char * const *trigger_chars;
g_assert (IDE_IS_LSP_COMPLETION_PROVIDER (self));
g_assert (iter != NULL);
- if (priv->trigger_chars != NULL)
+ trigger_chars = priv->trigger_chars ? (const char * const *)priv->trigger_chars : default_trigger_chars;
+
+ for (guint i = 0; trigger_chars[i]; i++)
{
- for (guint i = 0; priv->trigger_chars[i]; i++)
- {
- const char *trigger = priv->trigger_chars[i];
-
- /* Technically, since these are strings they can be more than
- * one character long. But I haven't seen anything actually
- * do that in the wild yet.
- */
- if (ch == g_utf8_get_char (trigger))
- return TRUE;
- }
+ if (ch == g_utf8_get_char (trigger_chars[i]))
+ return TRUE;
}
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]