Skip to content

Commit

Permalink
Remove hover provider count view setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann authored and rwols committed Feb 8, 2024
1 parent ab33520 commit 3423763
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion plugin/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Setting keys
CODE_LENS_ENABLED_KEY = 'lsp_show_code_lens'
HOVER_ENABLED_KEY = 'lsp_show_hover_popups'
HOVER_PROVIDER_COUNT_KEY = 'lsp_hover_provider_count'
SHOW_DEFINITIONS_KEY = 'show_definitions'

# Region flags
Expand Down
1 change: 1 addition & 0 deletions plugin/core/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ class AbstractViewListener(metaclass=ABCMeta):
TOTAL_ERRORS_AND_WARNINGS_STATUS_KEY = "lsp_total_errors_and_warnings"

view = cast(sublime.View, None)
hover_provider_count = 0

@abstractmethod
def session_async(self, capability: str, point: Optional[int] = None) -> Optional['Session']:
Expand Down
1 change: 1 addition & 0 deletions plugin/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def on_change() -> None:
self._completions_task = None # type: Optional[QueryCompletionsTask]
self._stored_selection = [] # type: List[sublime.Region]
self._should_format_on_paste = False
self.hover_provider_count = 0
self._setup()

def __del__(self) -> None:
Expand Down
5 changes: 2 additions & 3 deletions plugin/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from .code_actions import CodeActionsByConfigName
from .core.constants import HOVER_ENABLED_KEY
from .core.constants import HOVER_HIGHLIGHT_KEY
from .core.constants import HOVER_PROVIDER_COUNT_KEY
from .core.constants import SHOW_DEFINITIONS_KEY
from .core.open import lsp_range_from_uri_fragment
from .core.open import open_file_uri
Expand All @@ -22,7 +21,6 @@
from .core.sessions import SessionBufferProtocol
from .core.settings import userprefs
from .core.typing import List, Optional, Dict, Tuple, Sequence, Union
from .core.typing import cast
from .core.url import parse_uri
from .core.views import diagnostic_severity
from .core.views import first_selection_region
Expand Down Expand Up @@ -409,7 +407,8 @@ def run(self) -> None:
sublime.set_timeout_async(partial(self._update_views_async, enable))

def _has_hover_provider(self, view: sublime.View) -> bool:
return cast(int, view.settings().get(HOVER_PROVIDER_COUNT_KEY, 0)) > 0
listener = windows.listener_for_view(view)
return listener.hover_provider_count > 0 if listener else False

def _update_views_async(self, enable: bool) -> None:
window_manager = windows.lookup(self.window)
Expand Down
29 changes: 13 additions & 16 deletions plugin/session_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .core.constants import DOCUMENT_HIGHLIGHT_KIND_NAMES
from .core.constants import HOVER_ENABLED_KEY
from .core.constants import HOVER_HIGHLIGHT_KEY
from .core.constants import HOVER_PROVIDER_COUNT_KEY
from .core.constants import REGIONS_INITIALIZE_FLAGS
from .core.constants import SHOW_DEFINITIONS_KEY
from .core.promise import Promise
Expand Down Expand Up @@ -229,23 +228,21 @@ def _apply_auto_complete_triggers(
settings.set(self.AC_TRIGGERS_KEY, triggers)

def _increment_hover_count(self) -> None:
settings = self.view.settings()
count = settings.get(HOVER_PROVIDER_COUNT_KEY, 0)
if isinstance(count, int):
count += 1
settings.set(HOVER_PROVIDER_COUNT_KEY, count)
window = self.view.window()
if window and window.settings().get(HOVER_ENABLED_KEY, True):
settings.set(SHOW_DEFINITIONS_KEY, False)
listener = self.listener()
if not listener:
return
listener.hover_provider_count += 1
window = self.view.window()
if window and window.settings().get(HOVER_ENABLED_KEY, True):
self.view.settings().set(SHOW_DEFINITIONS_KEY, False)

def _decrement_hover_count(self) -> None:
settings = self.view.settings()
count = settings.get(HOVER_PROVIDER_COUNT_KEY)
if isinstance(count, int):
count -= 1
if count == 0:
settings.erase(HOVER_PROVIDER_COUNT_KEY)
self.reset_show_definitions()
listener = self.listener()
if not listener:
return
listener.hover_provider_count -= 1
if listener.hover_provider_count == 0:
self.reset_show_definitions()

def reset_show_definitions(self) -> None:
self.view.settings().erase(SHOW_DEFINITIONS_KEY)
Expand Down

0 comments on commit 3423763

Please sign in to comment.