Skip to content

Commit

Permalink
fix: allow tag names with colons in search (#765)
Browse files Browse the repository at this point in the history
* Refactor allowing colons

* fix formatting
  • Loading branch information
SkeleyM authored Feb 2, 2025
1 parent 80c7e81 commit 93fc28e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tagstudio/src/core/query_lang/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,23 @@ def __unquoted_string_or_constraint_type(self) -> Token:

start = self.pos

while self.current_char not in self.NOT_IN_ULITERAL and self.current_char is not None:
while self.current_char is not None:
if self.current_char in self.NOT_IN_ULITERAL:
if self.current_char == ":":
if len(out) == 0:
raise ParsingError(self.pos, self.pos)
constraint_type = ConstraintType.from_string(out)
if constraint_type is not None:
self.__advance()
return Token(TokenType.CONSTRAINTTYPE, constraint_type, start, self.pos)
else:
break

out += self.current_char
self.__advance()

end = self.pos - 1

if self.current_char == ":":
if len(out) == 0:
raise ParsingError(self.pos, self.pos)
self.__advance()
constraint_type = ConstraintType.from_string(out)
if constraint_type is None:
raise ParsingError(start, end, f'Invalid ContraintType "{out}"')
return Token(TokenType.CONSTRAINTTYPE, constraint_type, start, end)
else:
return Token(TokenType.ULITERAL, out, start, end)
return Token(TokenType.ULITERAL, out, start, end)

def __quoted_string(self) -> Token:
start = self.pos
Expand Down

0 comments on commit 93fc28e

Please sign in to comment.