Skip to content

Commit 391562b

Browse files
committed
revert: rollback to str.format for long lines (>120 chars)
Signed-off-by: Jack Cherng <[email protected]>
1 parent cb1af4f commit 391562b

File tree

7 files changed

+16
-9
lines changed

7 files changed

+16
-9
lines changed

plugin/completion.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def format_completion(
6262
details: list[str] = []
6363
if can_resolve_completion_items or item.get('documentation'):
6464
# Not using "make_command_link" in a hot path to avoid slow json.dumps.
65-
args = f'{{"view_id":{view_id},"command":"lsp_resolve_docs","args":{{"index":{index},"session_name":"{session_name}"}}}}'
65+
args = '{{"view_id":{},"command":"lsp_resolve_docs","args":{{"index":{},"session_name":"{}"}}}}'.format(
66+
view_id, index, session_name)
6667
href = f'subl:lsp_run_text_command_helper {args}'
6768
details.append(f"<a href='{href}'>More</a>")
6869
if lsp_label_detail and (lsp_label + lsp_label_detail).startswith(lsp_filter_text):

plugin/core/configurations.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def record_crash(self, config_name: str, exit_code: int, exception: Exception |
114114
self._crashes[config_name].append(now)
115115
timeout = now - RETRY_COUNT_TIMEDELTA
116116
crash_count = len([crash for crash in self._crashes[config_name] if crash > timeout])
117-
printf(f"{config_name} crashed ({crash_count} / {RETRY_MAX_COUNT} times in the last {RETRY_COUNT_TIMEDELTA.total_seconds()} seconds), exit code {exit_code}, exception: {exception}")
117+
printf("{} crashed ({} / {} times in the last {} seconds), exit code {}, exception: {}".format(
118+
config_name, crash_count, RETRY_MAX_COUNT, RETRY_COUNT_TIMEDELTA.total_seconds(), exit_code, exception))
118119
return crash_count < RETRY_MAX_COUNT
119120

120121
def _reenable_disabled_for_session(self, config_name: str) -> bool:

plugin/core/sessions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ def decode_semantic_token(
169169
# this approach is limited to consider at most one modifier for the scope lookup
170170
key = f"{token_type}.{token_modifier}"
171171
if key in tokens_scope_map_dict:
172-
scope = tokens_scope_map_dict[key] + f" meta.semantic-token.{token_type.lower()}.{token_modifier.lower()}.lsp"
172+
scope = tokens_scope_map_dict[key] + " meta.semantic-token.{}.{}.lsp".format(
173+
token_type.lower(), token_modifier.lower())
173174
break # first match wins (in case of multiple modifiers)
174175
else:
175176
scope = tokens_scope_map_dict[token_type]

plugin/core/tree_view.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def html(self, sheet_name: str, indent_level: int) -> str:
6161
icon_html = '<span class="{}" title="{}">{}</span>'.format(
6262
self._kind_class_name(self.kind[0]), self.kind[2], self.kind[1] if self.kind[1] else '&nbsp;')
6363
if self.command_url and self.tooltip:
64-
label_html = f'<a class="label" href="{self.command_url}" title="{html.escape(self.tooltip)}">{html.escape(self.label)}</a>'
64+
label_html = '<a class="label" href="{}" title="{}">{}</a>'.format(
65+
self.command_url, html.escape(self.tooltip), html.escape(self.label))
6566
elif self.command_url:
6667
label_html = f'<a class="label" href="{self.command_url}">{html.escape(self.label)}</a>'
6768
elif self.tooltip:
@@ -70,7 +71,8 @@ def html(self, sheet_name: str, indent_level: int) -> str:
7071
label_html = f'<span class="label">{html.escape(self.label)}</span>'
7172
description_html = f'<span class="description">{html.escape(self.description)}</span>' if \
7273
self.description else ''
73-
return f'<div class="tree-view-row">{indent_html + disclosure_button_html + icon_html + label_html + description_html}</div>'
74+
return '<div class="tree-view-row">{}</div>'.format(
75+
indent_html + disclosure_button_html + icon_html + label_html + description_html)
7476

7577
@staticmethod
7678
def _kind_class_name(kind_id: int) -> str:

plugin/core/views.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ def format_diagnostics_for_annotation(
701701
message = text2html(diagnostic.get('message') or '')
702702
source = diagnostic.get('source')
703703
line = f"[{text2html(source)}] {message}" if source else message
704-
content = f'<body id="annotation" class="{lsp_css().annotations_classname}"><style>{lsp_css().annotations}</style><div class="{css_class}">{line}</div></body>'
704+
content = '<body id="annotation" class="{}"><style>{}</style><div class="{}">{}</div></body>'.format(
705+
lsp_css().annotations_classname, lsp_css().annotations, css_class, line)
705706
annotations.append(content)
706707
return (annotations, color)
707708

plugin/core/windows.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ def incoming_notification(self, method: str, params: Any, unhandled: bool) -> No
659659
self.log(self._format_notification(direction, method), params)
660660

661661
def _format_response(self, direction: str, request_id: Any, duration: str) -> str:
662-
return f"[{RequestTimeTracker.formatted_now()}] {direction} {self._server_name} ({request_id}) (duration: {duration})"
662+
return "[{}] {} {} ({}) (duration: {})".format(
663+
RequestTimeTracker.formatted_now(), direction, self._server_name, request_id, duration)
663664

664665
def _format_request(self, direction: str, method: str, request_id: Any) -> str:
665666
return f"[{RequestTimeTracker.formatted_now()}] {direction} {self._server_name} {method} ({request_id})"

plugin/goto_diagnostic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ def open_location(session: Session, location: Location, flags: int = 0, group: i
270270
def diagnostic_html(config: ClientConfig, diagnostic: Diagnostic, base_dir: Path | None) -> sublime.Html:
271271
content = format_diagnostic_for_html(
272272
config, truncate_message(diagnostic), None if base_dir is None else str(base_dir))
273-
return sublime.Html(f'<style>{PREVIEW_PANE_CSS}</style><div class="diagnostics {format_severity(diagnostic_severity(diagnostic))}">{content}</div>')
274-
273+
return sublime.Html('<style>{}</style><div class="diagnostics {}">{}</div>'.format(
274+
PREVIEW_PANE_CSS, format_severity(diagnostic_severity(diagnostic)), content))
275275

276276
def truncate_message(diagnostic: Diagnostic, max_lines: int = 6) -> Diagnostic:
277277
lines = diagnostic["message"].splitlines()

0 commit comments

Comments
 (0)