[gnome-builder] vls: bind LSP client lazily for search



commit c8f80258f89a2ffbd8b666c91b609785d29daeda
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 12 12:52:23 2021 -0700

    vls: bind LSP client lazily for search
    
    This ensures that the client is not spawned unless another component has
    caused it to.
    
    That does have the side-effect of requiring the user to actually open
    something that requires vala before search results are displayed. Not the
    end of the world, but in the future it might be nicer to sniff this out.
    
    Fixes #1476

 src/plugins/vls/vala_langserv.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/vls/vala_langserv.py b/src/plugins/vls/vala_langserv.py
index 249517d10..3b8c6578a 100644
--- a/src/plugins/vls/vala_langserv.py
+++ b/src/plugins/vls/vala_langserv.py
@@ -154,6 +154,16 @@ class VlsService(Ide.Object):
         self._ensure_started()
         self.bind_property('client', provider, 'client', GObject.BindingFlags.SYNC_CREATE)
 
+    @classmethod
+    def bind_client_lazy(cls, provider):
+        """
+        This helper will bind the client to the provider, but only after the
+        client has started.
+        """
+        context = provider.get_context()
+        self = VlsService.from_context(context)
+        self.bind_property('client', provider, 'client', GObject.BindingFlags.SYNC_CREATE)
+
 class VlsDiagnosticProvider(Ide.LspDiagnosticProvider):
     def do_load(self):
         VlsService.bind_client(self)
@@ -189,6 +199,6 @@ class VlsHoverProvider(Ide.LspHoverProvider):
         self.props.priority = 100
         VlsService.bind_client(self)
 
-class VlsSearchProvider(Ide.LspSearchProvider, Ide.SearchProvider):
+class VlsSearchProvider(Ide.LspSearchProvider):
     def do_load(self, context):
-        VlsService.bind_client(self)
+        VlsService.bind_client_lazy(self)


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