mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWeb: Do not clear the selection, when query is not found
Fixes #4743
This commit is contained in:
parent
ad4634d0ed
commit
09463f147d
Notes:
github-actions[bot]
2025-05-26 09:24:03 +00:00
Author: https://github.com/chrisvis 🔰
Commit: 09463f147d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4757
Reviewed-by: https://github.com/gmta ✅
3 changed files with 8 additions and 2 deletions
|
@ -726,11 +726,11 @@ Page::FindInPageResult Page::find_in_page_previous_match()
|
|||
|
||||
void Page::update_find_in_page_selection(Vector<GC::Root<DOM::Range>> matches)
|
||||
{
|
||||
clear_selection();
|
||||
|
||||
if (matches.is_empty())
|
||||
return;
|
||||
|
||||
clear_selection();
|
||||
|
||||
auto current_range = matches[m_find_in_page_match_index];
|
||||
auto common_ancestor_container = current_range->common_ancestor_container();
|
||||
auto& document = common_ancestor_container->document();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Selection: [object Text] 0 - [object Text] 6
|
||||
Selection: [object Text] 0 - [object Text] 3
|
||||
Selection: [object Text] 0 - [object Text] 3
|
||||
Expected exception: IndexSizeError: Selection.getRangeAt() on empty Selection or with invalid argument
|
||||
|
|
|
@ -16,6 +16,11 @@ test(() => {
|
|||
document.querySelector('div').childNodes[0].deleteData(3, 3);
|
||||
showSelection();
|
||||
|
||||
// Try to find 'baz'.
|
||||
window.find('baz');
|
||||
// Selection should be untouched, since 'baz' was not found
|
||||
showSelection();
|
||||
|
||||
// Try to find 'bar'.
|
||||
getSelection().empty();
|
||||
window.find('bar');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue