Skip to content

Commit 6bbced9

Browse files
committed
moved notification logging functions to a separate file to avoid circular imports
1 parent d0e8f16 commit 6bbced9

File tree

8 files changed

+37
-36
lines changed

8 files changed

+37
-36
lines changed

plugin/code_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from .core.logging import notify_error
2+
from .core.logging_notify import notify_error
33
from .core.promise import Promise
44
from .core.protocol import CodeAction
55
from .core.protocol import CodeActionKind

plugin/core/logging.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from typing import Any, Optional
2+
from typing import Any
33
import traceback
44
import inspect
55
import sublime
@@ -39,31 +39,3 @@ def exception_log(message: str, ex: Exception) -> None:
3939
def printf(*args: Any, prefix: str = 'LSP') -> None:
4040
"""Print args to the console, prefixed by the plugin name."""
4141
print(prefix + ":", *args)
42-
43-
44-
def notify(window: sublime.Window | None, message: str, status_message: str = 'LSP: see console log…') -> None:
45-
"""Pick either of the 2 ways to show a user notification message:
46-
- via a detailed console message and a short status message
47-
- via a blocking modal dialog"""
48-
from .settings import userprefs
49-
if not window:
50-
return
51-
if userprefs().suppress_error_dialogs:
52-
window.status_message(status_message)
53-
print(message)
54-
else:
55-
sublime.message_dialog(message)
56-
57-
58-
def notify_error(window: sublime.Window | None, message: str, status_message: str = '❗LSP: see console log…') -> None:
59-
"""Pick either of the 2 ways to show a user error notification message:
60-
- via a detailed console message and a short status message
61-
- via a blocking error modal dialog"""
62-
from .settings import userprefs
63-
if not window:
64-
return
65-
if userprefs().suppress_error_dialogs:
66-
window.status_message(status_message)
67-
print(message)
68-
else:
69-
sublime.error_message(message)

plugin/core/logging_notify.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from __future__ import annotations
2+
import sublime
3+
from .settings import userprefs
4+
5+
6+
def notify(window: sublime.Window | None, message: str, status_message: str = 'LSP: see console log…') -> None:
7+
"""Pick either of the 2 ways to show a user notification message:
8+
- via a detailed console message and a short status message
9+
- via a blocking modal dialog"""
10+
if not window:
11+
return
12+
if userprefs().suppress_error_dialogs:
13+
window.status_message(status_message)
14+
print(message)
15+
else:
16+
sublime.message_dialog(message)
17+
18+
19+
def notify_error(window: sublime.Window | None, message: str, status_message: str = '❗LSP: see console log…') -> None:
20+
"""Pick either of the 2 ways to show a user error notification message:
21+
- via a detailed console message and a short status message
22+
- via a blocking error modal dialog"""
23+
if not window:
24+
return
25+
if userprefs().suppress_error_dialogs:
26+
window.status_message(status_message)
27+
print(message)
28+
else:
29+
sublime.error_message(message)

plugin/core/windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .diagnostics_storage import is_severity_included
88
from .logging import debug
99
from .logging import exception_log
10-
from .logging import notify
10+
from .logging_notify import notify
1111
from .message_request_handler import MessageRequestHandler
1212
from .panels import LOG_LINES_LIMIT_SETTING_NAME
1313
from .panels import MAX_LOG_LINES_LIMIT_OFF

plugin/core/workspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .types import matches_pattern
55
from .types import sublime_pattern_to_glob
66
from .url import filename_to_uri
7-
from .logging import notify
7+
from .logging_notify import notify
88
from typing import Any
99
import sublime
1010
import os

plugin/execute_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from .core.logging import notify
2+
from .core.logging_notify import notify
33
from .core.protocol import Error
44
from .core.protocol import ExecuteCommandParams
55
from .core.registry import LspTextCommand

plugin/rename.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .core.edit import parse_range
33
from .core.edit import parse_workspace_edit
44
from .core.edit import WorkspaceChanges
5-
from .core.logging import notify_error
5+
from .core.logging_notify import notify_error
66
from .core.protocol import PrepareRenameParams
77
from .core.protocol import PrepareRenameResult
88
from .core.protocol import Range

plugin/tooling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22
from .core.css import css
33
from .core.logging import debug
4-
from .core.logging import notify
5-
from .core.logging import notify_error
4+
from .core.logging_notify import notify
5+
from .core.logging_notify import notify_error
66
from .core.registry import windows
77
from .core.sessions import get_plugin
88
from .core.transports import create_transport

0 commit comments

Comments
 (0)