Skip to content
Open
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
28 changes: 26 additions & 2 deletions alot/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,36 @@ async def apply(self, ui):
if threadline_widget is None:
return

tags = [x for x in self.tagsstring.split(',') if x]

testquery = searchbuffer.querystring
thread = threadline_widget.get_thread()
if not self.allm:
testquery = "thread:%s" % thread.get_thread_id()

# Reduce time for tagging long threads by selecting only messages that
# need the update.
if self.action == 'add':
testquery += ' AND NOT ('
testquery += ' AND '.join(f'tag:{x}' for x in tags)
testquery += ')'
elif self.action == 'remove':
testquery += ' AND ('
testquery += ' OR '.join(f'tag:{x}' for x in tags)
testquery += ')'
elif self.action == 'set':
# The "set" action means replacing the current set of tags with the
# one passed on the command. We could skip messages where the
# current set is the same as the one passed, but there is no
# efficient and simple way of doing that.
pass
elif self.action == 'toggle':
# The "toggle" affects all matched messages, so there is no further
# filtering to do here.
pass
else:
logging.warning('unandled action %s', self.action)

Comment on lines +219 to +220
Copy link

Copilot AI Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo detected in the log message: 'unandled' should be 'unhandled'.

Suggested change
logging.warning('unandled action %s', self.action)
logging.warning('unhandled action %s', self.action)

Copilot uses AI. Check for mistakes.
Comment on lines +219 to +220
Copy link

Copilot AI Apr 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the warning message: consider changing 'unandled' to 'unhandled'.

Suggested change
logging.warning('unandled action %s', self.action)
logging.warning('unhandled action %s', self.action)

Copilot uses AI. Check for mistakes.
logging.debug('all? %s', self.allm)
logging.debug('q: %s', testquery)

Expand All @@ -217,8 +243,6 @@ def refresh():

ui.update()

tags = [x for x in self.tagsstring.split(',') if x]

try:
if self.action == 'add':
ui.dbman.tag(testquery, tags, remove_rest=False)
Expand Down
Loading