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

Fix MethodTypeNotRegisteredError #339

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ and this project adheres to [Semantic Versioning][semver].
### Fixed

- `pygls` no longer overrides the event loop for the current thread when given an explicit loop to use. ([#334])
- Fixed `MethodTypeNotRegisteredError` when registering a `TEXT_DOCUMENT_DID_SAVE` feature with options. ([#338])

[#328]: https://github.com/openlawlibrary/pygls/issues/328
[#334]: https://github.com/openlawlibrary/pygls/issues/334
[#338]: https://github.com/openlawlibrary/pygls/discussions/338
[#253]: https://github.com/openlawlibrary/pygls/pull/253


Expand Down
8 changes: 2 additions & 6 deletions pygls/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from lsprotocol.types import (
ClientCapabilities, CodeLensOptions, CompletionOptions,
DocumentLinkOptions, ExecuteCommandOptions, ImplementationOptions,
SaveOptions, SemanticTokensOptions, SemanticTokensRegistrationOptions,
SemanticTokensOptions, SemanticTokensRegistrationOptions,
SemanticTokensOptionsFullType1, ServerCapabilities,
ServerCapabilitiesWorkspaceType, SignatureHelpOptions,
TextDocumentSyncOptions, TypeDefinitionOptions,
Expand Down Expand Up @@ -110,11 +110,7 @@ def _with_text_doc_sync(self):
and TEXT_DOCUMENT_WILL_SAVE_WAIT_UNTIL in self.features
)
if TEXT_DOCUMENT_DID_SAVE in self.features:
if TEXT_DOCUMENT_DID_SAVE in self.feature_options:
include_text = self.feature_options[TEXT_DOCUMENT_DID_SAVE].include_text
save = SaveOptions(include_text=include_text)
else:
save = True
save = self.feature_options.get(TEXT_DOCUMENT_DID_SAVE, True)
else:
save = False

Expand Down
3 changes: 3 additions & 0 deletions pygls/lsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from lsprotocol.types import (
ALL_TYPES_MAP,
METHOD_TO_TYPES,
TEXT_DOCUMENT_DID_SAVE,
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL,
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA,
TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE,
Expand All @@ -29,6 +30,7 @@
WORKSPACE_WILL_DELETE_FILES,
WORKSPACE_WILL_RENAME_FILES,
FileOperationRegistrationOptions,
SaveOptions,
SemanticTokensLegend,
SemanticTokensRegistrationOptions,
ShowDocumentResult
Expand All @@ -41,6 +43,7 @@
ShowDocumentCallbackType = Callable[[ShowDocumentResult], None]

METHOD_TO_OPTIONS = {
TEXT_DOCUMENT_DID_SAVE: SaveOptions,
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL: Union[SemanticTokensLegend, SemanticTokensRegistrationOptions],
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA: Union[SemanticTokensLegend, SemanticTokensRegistrationOptions],
TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE: Union[SemanticTokensLegend, SemanticTokensRegistrationOptions],
Expand Down
Loading