Skip to content

Commit 0fa74ba

Browse files
authored
Pass server settings to new workspaces (#868)
1 parent 1a431d9 commit 0fa74ba

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

pyls/python_ls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ def m_workspace__did_change_workspace_folders(self, event=None, **_kwargs): # p
379379
workspace_config = config.Config(
380380
added_uri, self.config._init_opts,
381381
self.config._process_id, self.config._capabilities)
382+
workspace_config.update(self.config._settings)
382383
self.workspaces[added_uri] = Workspace(
383384
added_uri, self._endpoint, workspace_config)
384385

test/test_workspace.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,23 @@ def test_workspace_loads_pycodestyle_config(pyls, tmpdir):
242242

243243
seetings = pyls.workspaces[str(workspace3_dir)]._config.settings()
244244
assert seetings['plugins']['pycodestyle']['maxLineLength'] == 20
245+
246+
247+
def test_settings_of_added_workspace(pyls, tmpdir):
248+
test_uri = str(tmpdir.mkdir('Test123'))
249+
pyls.root_uri = test_uri
250+
pyls.workspace._root_uri = test_uri
251+
252+
# Set some settings for the server.
253+
server_settings = {'pyls': {'plugins': {'jedi': {'environment': '/usr/bin/python3'}}}}
254+
pyls.m_workspace__did_change_configuration(server_settings)
255+
256+
# Create a new workspace.
257+
workspace1 = {'uri': str(tmpdir.mkdir('NewTest456'))}
258+
event = {'added': [workspace1]}
259+
pyls.m_workspace__did_change_workspace_folders(event)
260+
261+
# Assert settings are inherited from the server config.
262+
workspace1_object = pyls.workspaces[workspace1['uri']]
263+
workspace1_jedi_settings = workspace1_object._config.plugin_settings('jedi')
264+
assert workspace1_jedi_settings == server_settings['pyls']['plugins']['jedi']

0 commit comments

Comments
 (0)