Skip to content

Commit cd3ef80

Browse files
committed
✨ Return empty SearchResult for no search result
Previously this was an empty array, but that's incompatible: it's missing ^#modseq`.
1 parent ca72ac4 commit cd3ef80

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/net/imap.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3155,7 +3155,13 @@ def search_internal(cmd, keys, charset = nil)
31553155
args = charset ? ["CHARSET", charset, *keys] : keys
31563156
synchronize do
31573157
send_command(cmd, *args)
3158-
clear_responses("SEARCH").last || []
3158+
search_result = clear_responses("SEARCH").last
3159+
if search_result
3160+
search_result
3161+
else
3162+
# warn NO_SEARCH_RESPONSE
3163+
SearchResult[]
3164+
end
31593165
end
31603166
end
31613167

test/net/imap/test_imap.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,9 +1264,11 @@ def seqset_coercible.to_sequence_set
12641264
server.on "SEARCH", &:done_ok
12651265
server.on "UID SEARCH", &:done_ok
12661266
found = imap.search ["subject", "hello"]
1267-
assert_equal [], found
1267+
assert_instance_of Net::IMAP::SearchResult, found
1268+
assert_empty found
12681269
found = imap.uid_search ["subject", "hello"]
1269-
assert_equal [], found
1270+
assert_instance_of Net::IMAP::SearchResult, found
1271+
assert_empty found
12701272
end
12711273
end
12721274

0 commit comments

Comments
 (0)