Skip to content

Commit

Permalink
✨ Return empty SearchResult for no search result
Browse files Browse the repository at this point in the history
Previously this was an empty array, but that's incompatible: it's
missing ^#modseq`.
  • Loading branch information
nevans committed Dec 14, 2024
1 parent ca72ac4 commit cd3ef80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3155,7 +3155,13 @@ def search_internal(cmd, keys, charset = nil)
args = charset ? ["CHARSET", charset, *keys] : keys
synchronize do
send_command(cmd, *args)
clear_responses("SEARCH").last || []
search_result = clear_responses("SEARCH").last
if search_result
search_result
else
# warn NO_SEARCH_RESPONSE
SearchResult[]
end
end
end

Expand Down
6 changes: 4 additions & 2 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1264,9 +1264,11 @@ def seqset_coercible.to_sequence_set
server.on "SEARCH", &:done_ok
server.on "UID SEARCH", &:done_ok
found = imap.search ["subject", "hello"]
assert_equal [], found
assert_instance_of Net::IMAP::SearchResult, found
assert_empty found
found = imap.uid_search ["subject", "hello"]
assert_equal [], found
assert_instance_of Net::IMAP::SearchResult, found
assert_empty found
end
end

Expand Down

0 comments on commit cd3ef80

Please sign in to comment.