[gnome-builder: 15/17] lsp: fixed lsp notifications if multiple requests happening
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 15/17] lsp: fixed lsp notifications if multiple requests happening
- Date: Mon, 22 Jun 2020 19:23:52 +0000 (UTC)
commit b993e563b9c6bfcd78806c7d9871e735892ebc90
Author: Günther Wagner <info gunibert de>
Date: Thu Jun 4 21:10:24 2020 +0200
lsp: fixed lsp notifications if multiple requests happening
src/libide/lsp/ide-lsp-client.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/src/libide/lsp/ide-lsp-client.c b/src/libide/lsp/ide-lsp-client.c
index 9600e6987..e73ef6d13 100644
--- a/src/libide/lsp/ide-lsp-client.c
+++ b/src/libide/lsp/ide-lsp-client.c
@@ -750,13 +750,14 @@ ide_lsp_client_real_notification (IdeLspClient *self,
}
else if (g_str_equal (method, "$/progress"))
{
+ gboolean notification_exists = FALSE;
const gchar *token = NULL;
const gchar *message = NULL;
const gchar *title = NULL;
const gchar *kind = NULL;
IdeContext *context;
IdeNotifications *notifications;
- IdeNotification *notification;
+ IdeNotification *notification = NULL;
JSONRPC_MESSAGE_PARSE (params, "token", JSONRPC_MESSAGE_GET_STRING (&token),
"value", "{",
@@ -770,26 +771,36 @@ ide_lsp_client_real_notification (IdeLspClient *self,
"}");
context = ide_object_get_context (IDE_OBJECT (self));
notifications = ide_object_get_child_typed (IDE_OBJECT (context), IDE_TYPE_NOTIFICATIONS);
+ notification = ide_notifications_find_by_id (notifications, token);
+ if (notification == NULL)
+ notification_exists = FALSE;
+ else
+ notification_exists = TRUE;
if (ide_str_equal0 (kind, "begin"))
{
- notification = ide_notification_new ();
- ide_notification_set_id (notification, token);
- ide_notification_set_has_progress (notification, TRUE);
- ide_notification_set_progress_is_imprecise (notification, TRUE);
+ if (!notification_exists)
+ {
+ notification = ide_notification_new ();
+ ide_notification_set_id (notification, token);
+ ide_notification_set_has_progress (notification, TRUE);
+ ide_notification_set_progress_is_imprecise (notification, TRUE);
+ }
+
ide_notification_set_title (notification, title);
ide_notification_set_body (notification, message != NULL ? message : title);
- ide_notification_attach (notification, IDE_OBJECT (context));
+
+ if (!notification_exists)
+ ide_notification_attach (notification, IDE_OBJECT (context));
}
else
{
- notification = ide_notifications_find_by_id (notifications, token);
if (message != NULL && notification != NULL)
ide_notification_set_body (notification, message);
}
if (ide_str_equal0 (kind, "end") && notification != NULL)
- ide_notification_withdraw_in_seconds (notification, 3);
+ ide_notification_withdraw (notification);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]