Skip to content

Commit

Permalink
Update generic tokens and if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosems committed Sep 7, 2024
1 parent 80113d9 commit 341e07b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions token_tools/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
Token = tuple[tuple[int, int], int, str]

GENERIC_TOKENS: list[str] = [
"Whitespace",
"Text",
"Identifier", # Variable
"Error",
"Keyword",
"Name",
"Type",
"String",
"Number",
"Literal",
"Operator",
"Punctuation",
"Comment",
"Generic",
]
6 changes: 3 additions & 3 deletions token_tools/token_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def normal_text_range(
"""Takes the full text and a text range (inclusively numbered) and returns the split text and a tuple with the proper text range."""
# Text range is the first and last line inclusively with -1 for the end line indicating that it goes until the last line
split_text: list[str] = full_text.splitlines()
split_len: int = len(split_text)

if text_range[1] == -1:
# This indicates that the text range should span the length of the entire code
split_len: int = len(split_text)
if text_range[1] > split_len or text_range[1] == -1:
# This indicates that the text range should span the length of the entire code or is too long
split_len = (
1 if split_len == 0 else split_len
) # If its a one line code snippet, we need to +1
Expand Down

0 comments on commit 341e07b

Please sign in to comment.