Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel output/regex fixes. #1883

Merged
merged 2 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Syntaxes/Diagnostics.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ contexts:
- include: line

file:
- match: ^(?!\s*\d+:\d+)(.*)(:)$
- match: ^(\S.*)(:)$
scope: meta.diagnostic.preamble.lsp
captures:
0: meta.diagnostic.preamble.lsp
1: entity.name.filename.lsp
2: punctuation.separator.lsp

line:
- match: ^\s*(?=\d)
- match: ^\s+(?=\d)
push:
- ensure-diag-meta-scope
- expect-source-and-code
Expand Down
10 changes: 3 additions & 7 deletions Syntaxes/References.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@
hidden: true
scope: output.lsp.references

variables:
start_of_reference_body: ^\s*(?=\s*\d+:\d+)
filename_and_colon: ^(?!\s*\d+:\d+)(.*)(:)$

contexts:
main:
- include: references-preamble
- include: references-body

references-preamble:
- match: '{{filename_and_colon}}'
- match: ^(\S.*)(:)$
scope: meta.reference.preamble.lsp
captures:
0: meta.reference.preamble.lsp
1: entity.name.filename.lsp
2: punctuation.separator.lsp

references-body:
- match: '{{start_of_reference_body}}'
- match: ^\s+(?=\d+)
push:
- ensure-reference-meta-scope
- code
Expand Down
2 changes: 1 addition & 1 deletion plugin/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
TCP_CONNECT_TIMEOUT = 5 # seconds
FEATURES_TIMEOUT = 300 # milliseconds

PANEL_FILE_REGEX = r"^(?!\s+\d+:\d+)(.*)(:)$"
PANEL_FILE_REGEX = r"^(\S.*):$"
PANEL_LINE_REGEX = r"^\s+(\d+):(\d+)"

FileWatcherConfig = TypedDict("FileWatcherConfig", {
Expand Down
4 changes: 2 additions & 2 deletions plugin/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def format_diagnostic_for_panel(diagnostic: Diagnostic) -> Tuple[str, Optional[i
formatted.append(code)
lines = diagnostic["message"].splitlines() or [""]
# \u200B is the zero-width space
result = "{:>5}:{:<4}{:<8}{} \u200B{}".format(
result = " {:>4}:{:<4}{:<8}{} \u200B{}".format(
diagnostic["range"]["start"]["line"] + 1,
diagnostic["range"]["start"]["character"] + 1,
format_severity(diagnostic_severity(diagnostic)),
Expand All @@ -671,7 +671,7 @@ def format_diagnostic_for_panel(diagnostic: Diagnostic) -> Tuple[str, Optional[i
if href:
offset = len(result)
for line in itertools.islice(lines, 1, None):
result += "\n" + 17 * " " + line
result += "\n" + 18 * " " + line
return result, offset, code, href


Expand Down
2 changes: 1 addition & 1 deletion plugin/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _show_references_in_output_panel(self, word: str, session: Session, location
for reference in references:
references_count += 1
point, line = reference
to_render.append('{:>5}:{:<4} {}'.format(point.row + 1, point.col + 1, line))
to_render.append(" {:>4}:{:<4} {}".format(point.row + 1, point.col + 1, line))
to_render.append("") # add spacing between filenames
characters = "\n".join(to_render)
panel.settings().set("result_base_dir", base_dir)
Expand Down
2 changes: 1 addition & 1 deletion plugin/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _render_rename_panel(
for edit in file_changes:
start = edit[0]
line_content = get_line(window, file, start[0])
to_render.append('{:>5}:{:<4} {}'.format(start[0] + 1, start[1] + 1, line_content))
to_render.append(" {:>4}:{:<4} {}".format(start[0] + 1, start[1] + 1, line_content))
to_render.append("") # this adds a spacing between filenames
characters = "\n".join(to_render)
base_dir = windows.lookup(window).get_project_path(self.view.file_name() or "")
Expand Down