diff --git a/plugin/core/edit.py b/plugin/core/edit.py index 6795c3791..47995c9b9 100644 --- a/plugin/core/edit.py +++ b/plugin/core/edit.py @@ -1,6 +1,5 @@ from __future__ import annotations from .logging import debug -from .protocol import is_text_edit from .protocol import Position from .protocol import TextEdit from .protocol import UINT_MAX @@ -25,11 +24,11 @@ def parse_workspace_edit(workspace_edit: WorkspaceEdit) -> WorkspaceChanges: uri = text_document['uri'] version = text_document.get('version') edits = document_change.get('edits') - changes.setdefault(uri, ([], version))[0].extend( - # currently LSP code supprots only `TextEdit`s - # TODO: Extend WorkspaceEdit to support `AnnotatedTextEdit` and `SnippetTextEdit` - [edit for edit in edits if is_text_edit(edit)] - ) + for edit in edits: + if 'annotationId' in edit or 'snippet' in edit: + debug('Ignoring unsupported edit type') + continue + changes.setdefault(uri, ([], version))[0].append(edit) else: raw_changes = workspace_edit.get('changes') if isinstance(raw_changes, dict): diff --git a/plugin/core/protocol.py b/plugin/core/protocol.py index f2e9aa651..69a440f72 100644 --- a/plugin/core/protocol.py +++ b/plugin/core/protocol.py @@ -3,7 +3,7 @@ from enum import IntEnum, IntFlag from functools import total_ordering from typing import Any, Dict, Generic, Iterable, List, Literal, Mapping, TypedDict, TypeVar, Union -from typing_extensions import NotRequired, TypeGuard +from typing_extensions import NotRequired import sublime INT_MAX = 2**31 - 1 @@ -6282,7 +6282,3 @@ def to_lsp(self) -> Position: # Temporary for backward compatibility with LSP packages. RangeLsp = Range - - -def is_text_edit(value: Any) -> TypeGuard[TextEdit]: - return isinstance(value, dict) and 'range' in value and 'newText' in value