Skip to content

Commit

Permalink
Fix small issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosems committed Sep 8, 2024
1 parent 0746f62 commit 0955701
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion salve/server_functions/highlight/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def normal_text_range(
def get_new_token_type(token: str) -> str | None:
"""Turns pygments token types into a generic predefined Token"""
for old_token, new_token in default_tokens.items():
if old_token.startswith(token):
if token.startswith(old_token):
return new_token

return None
1 change: 1 addition & 0 deletions salve/server_functions/links_and_hidden_chars.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def get_urls(whole_text: str, text_range: tuple[int, int]) -> list[Token]:
while True:
if start_pos[0] > text_range[1]:
break

line: str = lines[start_pos[0] - text_range[0]][start_pos[1] :]
match_start: Match[str] | None = url_regex.search(line)
if match_start is None:
Expand Down
15 changes: 14 additions & 1 deletion tests/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,36 @@ def test_IPC():
"cancelled": False,
"command": "highlight",
"result": [
((1, 0), 4, "Keyword"),
((1, 5), 4, "Identifier"),
((1, 10), 6, "Keyword"),
((1, 17), 1, "Identifier"),
((1, 20), 12, "Comment"),
((3, 0), 3, "Identifier"),
((3, 3), 1, "Punctuation"),
((3, 5), 4, "Identifier"),
((3, 10), 1, "Operator"),
((3, 12), 3, "Identifier"),
((4, 0), 1, "Punctuation"),
((4, 1), 3, "Identifier"),
((4, 5), 2, "Operator"),
((4, 8), 4, "Identifier"),
((4, 12), 1, "Punctuation"),
((4, 15), 12, "Comment"),
((6, 0), 5, "Identifier"),
((6, 5), 2, "Punctuation"),
((9, 0), 5, "Keyword"),
((9, 6), 3, "Identifier"),
((9, 9), 1, "Punctuation"),
((9, 10), 3, "Identifier"),
((9, 13), 2, "Punctuation"),
((11, 4), 4, "Identifier"),
((10, 4), 3, "String"),
((11, 4), 4, "String"),
((12, 4), 3, "String"),
((14, 4), 3, "Keyword"),
((14, 8), 8, "Identifier"),
((14, 16), 1, "Punctuation"),
((14, 17), 4, "Identifier"),
((14, 21), 2, "Punctuation"),
((15, 8), 4, "Keyword"),
((18, 0), 3, "Identifier"),
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_file1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from this import s # noqa: F401

Bar: type = int
(xyz := test)
(xyz := test) # noqa: F821

print()

Expand Down

0 comments on commit 0955701

Please sign in to comment.