Skip to content

Commit

Permalink
Fix bug when no new_tokens exist (#61)
Browse files Browse the repository at this point in the history
* Fix bug when no new_tokens exist

if no new_tokens existed it would not give out any new tokens since the overwrite method did not have anything to compare against.

* Format

* Bump version
  • Loading branch information
Moosems authored Jul 10, 2024
1 parent 578a2ea commit 32d2afb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center">Salve v0.7.0</h1>
<h1 align="center">Salve v0.7.1</h1>

# Installation

Expand Down
2 changes: 1 addition & 1 deletion salve_ipc/server_functions/highlight/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_highlights(
# Lexer adds the newline back as its own token
continue

if not token_str.strip() and new_type == "Text":
if not token_str.strip() or new_type == "Text":
# If the token is empty or is plain Text we simply skip it because thats ultimately useless info
start_index = (start_index[0], start_index[1] + token_len)
continue
Expand Down
3 changes: 3 additions & 0 deletions salve_ipc/server_functions/highlight/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def merge_tokens(tokens: list[Token]) -> list[Token]:


def overwrite_tokens(old_tokens: list[Token], new_tokens: list[Token]):
if not new_tokens:
return old_tokens

output_tokens: list[Token] = []
dont_add_tokens: list[Token] = []
for new_token in new_tokens:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="salve_ipc",
version="0.7.0",
version="0.7.1",
description="Salve is an IPC library that can be used by code editors to easily get autocompletions, replacements, editorconfig suggestions, definitions, and syntax highlighting.",
author="Moosems",
author_email="[email protected]",
Expand Down
9 changes: 9 additions & 0 deletions tests/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ def test_IPC():

assert highlight_output == expected_output

context.update_file(
"foo", open(Path("tests/testing_file2.py"), "r+").read()
)
context.request(HIGHLIGHT, file="foo", language="python")
while not (output := context.get_response(HIGHLIGHT)):
pass
response = output["result"] # type: ignore
assert response != []

context.remove_file("test")
context.kill_IPC()

Expand Down

0 comments on commit 32d2afb

Please sign in to comment.