Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protect again invalid auto_complete_triggers values #2209

Merged
merged 2 commits into from
Feb 26, 2023
Merged

Conversation

rchl
Copy link
Member

@rchl rchl commented Feb 25, 2023

could crash with invalid user values: TerminalFi/LSP-copilot#90

@rchl rchl merged commit 8b28c7e into main Feb 26, 2023
@rchl rchl deleted the fix/trigger-check branch February 26, 2023 20:25
@neverbot
Copy link

neverbot commented Feb 27, 2023

@rchl sorry for the mention, i'm completely lost as this was working and suddenly it stopped... have no clue what is causing it, but the log shows the same as the issue in LSP-copilot: TerminalFi/LSP-copilot#90,

... but my auto_complete_triggers setting in ST is the default one, I've never changed it:

	// Additional situations to trigger auto complete
	"auto_complete_triggers":
	[
		{"selector": "text.html, text.xml", "characters": "<"},
		{"selector": "punctuation.accessor", "rhs_empty": true},
	],
failed to register session LSP-copilot to listener ViewListener(139)
Traceback (most recent call last):
  File "/Users/ialonso/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 183, in _publish_sessions_to_listener_async
    listener.on_session_initialized_async(session)
  File "/Users/ialonso/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/documents.py", line 210, in on_session_initialized_async
    self._session_views[session.config.name] = SessionView(self, session, self._uri)
  File "/Users/ialonso/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/session_view.py", line 63, in __init__
    self._clear_auto_complete_triggers(settings)
  File "/Users/ialonso/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/session_view.py", line 152, in _clear_auto_complete_triggers
    triggers = [t for t in triggers if self.session.config.name != t.get("server", "")]
  File "/Users/ialonso/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/session_view.py", line 152, in <listcomp>
    triggers = [t for t in triggers if self.session.config.name != t.get("server", "")]
AttributeError: 'str' object has no attribute 'get'

Do you think it could be related? if it has no relation should I open a new issue (not sure if in LSP or in LSP-copilot)?

Tried to remove both packages multiple times and installed them again 🤷‍♂️

Edit: I've removed everything, reinstalled sublime again with only these two packages, and seems to work again. Will edit if it happens again. I'll try to reinstall every package I was using.

@rchl
Copy link
Member Author

rchl commented Feb 27, 2023

This fix is not released yet so it would not help with your issue at this point.

The invalid setting could in theory be set by some random package dynamically for open file in which case you wouldn't see it in preferences.

If you stumble upon this issue then you can run view.settings().get('auto_complete_triggers') in the ST console and you should see the faulty entry. Maybe it would be clear when seeing it which package has set it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants