From 4622934e7c4e1ef50aadc6de618358e88c07facc Mon Sep 17 00:00:00 2001 From: Luciano Martorella Date: Wed, 17 May 2023 16:29:42 +0200 Subject: [PATCH 1/2] - Honor the OPTION_ROBOT_TIMEOUT_USE for initialization as well --- .../src/robotframework_ls/server_api/client.py | 15 +++++++++++++-- .../src/robotframework_ls/server_manager.py | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/robotframework-ls/src/robotframework_ls/server_api/client.py b/robotframework-ls/src/robotframework_ls/server_api/client.py index a526041306..4cd7098562 100644 --- a/robotframework-ls/src/robotframework_ls/server_api/client.py +++ b/robotframework-ls/src/robotframework_ls/server_api/client.py @@ -54,12 +54,23 @@ def _check_process_alive(self, raise_exception=True): return True def initialize( - self, msg_id=None, process_id=None, root_uri="", workspace_folders=() + self, config, msg_id=None, process_id=None, root_uri="", workspace_folders=() ): from robocorp_ls_core.options import NO_TIMEOUT, USE_TIMEOUTS self._check_process_alive() msg_id = msg_id if msg_id is not None else self.next_id() + + from robotframework_ls.impl.robot_generated_lsp_constants import ( + OPTION_ROBOT_TIMEOUT_USE, + ) + + timeout=30 + if config and not config.get_setting(OPTION_ROBOT_TIMEOUT_USE, bool, USE_TIMEOUTS): + timeout=NO_TIMEOUT + if not USE_TIMEOUTS: + timeout=NO_TIMEOUT + return self.request( { "jsonrpc": "2.0", @@ -71,7 +82,7 @@ def initialize( "workspaceFolders": workspace_folders, }, }, - timeout=30 if USE_TIMEOUTS else NO_TIMEOUT, + timeout=timeout, ) @implements(IRobotFrameworkApiClient.settings) diff --git a/robotframework-ls/src/robotframework_ls/server_manager.py b/robotframework-ls/src/robotframework_ls/server_manager.py index c34f597f24..ede94ab577 100644 --- a/robotframework-ls/src/robotframework_ls/server_manager.py +++ b/robotframework-ls/src/robotframework_ls/server_manager.py @@ -327,7 +327,9 @@ def on_received_message(msg): os.getpid(), server_process.pid, ) + config = self._config api.initialize( + config, process_id=os.getpid(), root_uri=workspace.root_uri, workspace_folders=list( @@ -336,7 +338,6 @@ def on_received_message(msg): ), ) - config = self._config log.debug("Forwarding config to api...") if config is not None: api.forward( From 2bd8f687a11bded2b6d005be4a8b66b6f75433f1 Mon Sep 17 00:00:00 2001 From: Luciano Martorella Date: Thu, 8 Jun 2023 15:02:00 +0200 Subject: [PATCH 2/2] - Linted --- .../src/robotframework_ls/server_api/client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/robotframework-ls/src/robotframework_ls/server_api/client.py b/robotframework-ls/src/robotframework_ls/server_api/client.py index 4cd7098562..c339c7cdf7 100644 --- a/robotframework-ls/src/robotframework_ls/server_api/client.py +++ b/robotframework-ls/src/robotframework_ls/server_api/client.py @@ -65,11 +65,13 @@ def initialize( OPTION_ROBOT_TIMEOUT_USE, ) - timeout=30 - if config and not config.get_setting(OPTION_ROBOT_TIMEOUT_USE, bool, USE_TIMEOUTS): - timeout=NO_TIMEOUT + timeout = 30 + if config and not config.get_setting( + OPTION_ROBOT_TIMEOUT_USE, bool, USE_TIMEOUTS + ): + timeout = NO_TIMEOUT if not USE_TIMEOUTS: - timeout=NO_TIMEOUT + timeout = NO_TIMEOUT return self.request( {