Skip to content

Commit

Permalink
Created a mixing with TextCommand and LspTextCommand, issue:
Browse files Browse the repository at this point in the history
Not add base classes to its internal `text_command_classes` and etc variables
sublimehq/sublime_text#2175
  • Loading branch information
evandrocoan committed Feb 1, 2018
1 parent b0f6de3 commit af5bb11
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
4 changes: 3 additions & 1 deletion plugin/code_actions.py
@@ -1,5 +1,7 @@
import sublime

from sublime_plugin import TextCommand

try:
from typing import Any, List
assert Any and List
Expand All @@ -15,7 +17,7 @@
from .core.url import filename_to_uri


class LspCodeActionsCommand(LspTextCommand):
class LspCodeActionsCommand(LspTextCommand, TextCommand):
def __init__(self, view):
super(LspCodeActionsCommand, self).__init__(view, 'codeActionProvider')

Expand Down
5 changes: 2 additions & 3 deletions plugin/core/clients.py
Expand Up @@ -23,9 +23,8 @@
clients_by_window = {} # type: Dict[int, Dict[str, Client]]


class LspTextCommand(TextCommand):
# Passing capability='' due Sublime Text bug: https://github.com/SublimeTextIssues/Core/issues/2175
def __init__(self, view, capability='', last_check=lambda: True):
class LspTextCommand(object):
def __init__(self, view, capability, last_check=lambda: True):
super(LspTextCommand, self).__init__(view)
self.capability = capability
self.last_check = last_check
Expand Down
4 changes: 3 additions & 1 deletion plugin/definition.py
@@ -1,5 +1,7 @@
import sublime

from sublime_plugin import TextCommand

from .core.clients import LspTextCommand
from .core.clients import client_for_view
from .core.protocol import Request, Point
Expand All @@ -8,7 +10,7 @@
from .core.logging import debug


class LspSymbolDefinitionCommand(LspTextCommand):
class LspSymbolDefinitionCommand(LspTextCommand, TextCommand):
def __init__(self, view):
super(LspSymbolDefinitionCommand, self).__init__(view, 'definitionProvider')

Expand Down
6 changes: 4 additions & 2 deletions plugin/formatting.py
@@ -1,11 +1,13 @@

from sublime_plugin import TextCommand

from .core.protocol import Request, Range
from .core.url import filename_to_uri
from .core.clients import client_for_view
from .core.clients import LspTextCommand


class LspFormatDocumentCommand(LspTextCommand):
class LspFormatDocumentCommand(LspTextCommand, TextCommand):
def __init__(self, view):
super(LspFormatDocumentCommand, self).__init__(view, 'documentFormattingProvider')

Expand All @@ -31,7 +33,7 @@ def handle_response(self, response, pos):
{'changes': response})


class LspFormatDocumentRangeCommand(LspTextCommand):
class LspFormatDocumentRangeCommand(LspTextCommand, TextCommand):
def __init__(self, view):
def last_check():
if len(self.view.sel()) == 1:
Expand Down
4 changes: 3 additions & 1 deletion plugin/references.py
@@ -1,6 +1,8 @@
import os
import sublime

from sublime_plugin import TextCommand

from .core.panels import create_output_panel
from .core.settings import PLUGIN_NAME
from .core.clients import client_for_view
Expand Down Expand Up @@ -28,7 +30,7 @@ def create_references_panel(window: sublime.Window):
return panel


class LspSymbolReferencesCommand(LspTextCommand):
class LspSymbolReferencesCommand(LspTextCommand, TextCommand):
def __init__(self, view):
super(LspSymbolReferencesCommand, self).__init__(view, 'referencesProvider', lambda: is_at_word(view, None))

Expand Down
4 changes: 3 additions & 1 deletion plugin/rename.py
@@ -1,11 +1,13 @@

from sublime_plugin import TextCommand

from .core.clients import LspTextCommand
from .core.clients import client_for_view
from .core.protocol import Request
from .core.documents import get_document_position, get_position, is_at_word


class LspSymbolRenameCommand(LspTextCommand):
class LspSymbolRenameCommand(LspTextCommand, TextCommand):
def __init__(self, view):
# TODO: check what kind of scope we're in.
super(LspSymbolRenameCommand, self).__init__(view, 'renameProvider', lambda: is_at_word(view, None))
Expand Down
4 changes: 3 additions & 1 deletion plugin/symbols.py
@@ -1,4 +1,6 @@

from sublime_plugin import TextCommand

from .core.protocol import SymbolKind
from .core.clients import LspTextCommand
from .core.clients import client_for_view
Expand Down Expand Up @@ -36,7 +38,7 @@ def format_symbol(item):
return [label, format_symbol_kind(item.get("kind"))]


class LspDocumentSymbolsCommand(LspTextCommand):
class LspDocumentSymbolsCommand(LspTextCommand, TextCommand):
def __init__(self, view):
super(LspDocumentSymbolsCommand, self).__init__(view, 'documentSymbolProvider')

Expand Down

0 comments on commit af5bb11

Please sign in to comment.