From b07c361b863b413a3dcea87ac120ef10b1a24244 Mon Sep 17 00:00:00 2001 From: palmoni5 Date: Fri, 13 Nov 2026 01:35:04 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=D7=97=D7=99=D7=A4=D7=95=D7=A9:=20=D7=94?= =?UTF-8?q?=D7=91=D7=97=D7=A0=D7=94=20=D7=91=D7=94=D7=A2=D7=A8=D7=95=D7=AA?= =?UTF-8?q?=20=D7=A9=D7=95=D7=9C=D7=99=D7=99=D7=9D=20=D7=95=D7=A9=D7=9E?= =?UTF-8?q?=D7=99=D7=A8=D7=AA=20=D7=A1=D7=99=D7=9E=D7=95=D7=A0=D7=99=20?= =?UTF-8?q?=D7=94=D7=94=D7=A2=D7=A8=D7=94=20=D7=91=D7=A7=D7=98=D7=A2=D7=99?= =?UTF-8?q?=20=D7=94=D7=AA=D7=95=D7=A6=D7=90=D7=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit המנוע מסמן בקטעי התוצאה את גוף ההערה ואת סמן ההערה בתגיות otzaria-note ו-otzaria-note-marker. בונה הקטעים מציג גוף הערה כ-[הערה: ...] בכתב נטוי ומקטין את הסמן, כך שהתאמה בתוך הערה אינה נראית כחלק מגוף הספר. הסימונים נשמרים גם כשטווחי ההדגשה מחושבים מחדש, בתוצאות החיפוש הכללי, בחיפוש בספר ובתוצאות הסמנטיות, וכן בהעתקת תוצאה. HTML ישן בלי תגיות הערה ממשיך להיות מוצג בסגנונותיו המקוריים. --- lib/search/utils/search_result_copy.dart | 16 +- lib/search/utils/snippet_builder.dart | 194 ++++- .../models/semantic_feedback_snapshots.dart | 2 +- .../view/semantic_search_results_screen.dart | 9 +- .../view/text_book_search_screen.dart | 1 + .../snippet_note_annotations_engine_test.dart | 111 +++ .../search/snippet_note_annotations_test.dart | 345 +++++++++ test/search/tantivy_search_results_test.dart | 57 +- .../semantic_mode_gate_test.dart | 30 +- .../semantic_results_screen_test.dart | 102 ++- .../text_book_search_engine_route_test.dart | 688 +++++++++--------- 11 files changed, 1159 insertions(+), 396 deletions(-) create mode 100644 test/search/snippet_note_annotations_engine_test.dart create mode 100644 test/search/snippet_note_annotations_test.dart diff --git a/lib/search/utils/search_result_copy.dart b/lib/search/utils/search_result_copy.dart index 6f37e1c224..e9f0ef4f2d 100644 --- a/lib/search/utils/search_result_copy.dart +++ b/lib/search/utils/search_result_copy.dart @@ -1,5 +1,6 @@ import 'package:flutter/services.dart'; import 'package:otzaria/core/ui_snack.dart'; +import 'package:otzaria/search/utils/snippet_builder.dart'; import 'package:otzaria/settings/settings_exports.dart'; import 'package:otzaria/utils/text/copy_utils.dart'; import 'package:otzaria/utils/text/text_manipulation.dart' as utils; @@ -13,14 +14,11 @@ void copySearchResultText({ required String titleText, required SettingsState settingsState, }) { - final plainText = utils.stripHtmlPreservingBreaks( - rawHtml, - ); + final plainText = + SnippetBuilder.annotatedPlainText(rawHtml) ?? + utils.stripHtmlPreservingBreaks(rawHtml); final bookName = settingsState.replaceHolyNames - ? utils.replaceHolyNames( - result.title, - style: settingsState.holyNameStyle, - ) + ? utils.replaceHolyNames(result.title, style: settingsState.holyNameStyle) : result.title; final textToCopy = CopyUtils.formatTextWithHeaders( originalText: plainText, @@ -32,8 +30,6 @@ void copySearchResultText({ reference: titleText, ), ); - Clipboard.setData( - ClipboardData(text: textToCopy), - ); + Clipboard.setData(ClipboardData(text: textToCopy)); UiSnack.show(UiSnack.textCopied); } diff --git a/lib/search/utils/snippet_builder.dart b/lib/search/utils/snippet_builder.dart index 1a377ce6a0..8574db2539 100644 --- a/lib/search/utils/snippet_builder.dart +++ b/lib/search/utils/snippet_builder.dart @@ -70,6 +70,7 @@ class SnippetBuilder { _appendHtmlSpans( body, style: defaultStyle, + defaultStyle: defaultStyle, spans: spans, highlightStyle: highlightStyle, markStyle: markStyle ?? highlightStyle, @@ -85,19 +86,40 @@ class SnippetBuilder { static void _appendHtmlSpans( dom.Node node, { required TextStyle style, + required TextStyle defaultStyle, required List spans, required TextStyle highlightStyle, required TextStyle markStyle, bool highlighted = false, + bool inNote = false, + bool inMarker = false, }) { for (final child in node.nodes) { if (child is dom.Text) { final text = _collapseWhitespace(child.text); if (text.isEmpty) continue; - spans.add(TextSpan(text: text, style: style)); + spans.add( + TextSpan( + text: text, + style: _annotationStyle( + style, + defaultStyle, + note: inNote, + marker: inMarker, + ), + ), + ); } else if (child is dom.Element) { final tag = child.localName; final opens = !highlighted && _highlightTags.contains(tag); + final opensNote = + tag == 'otzaria-note' && + !inNote && + _collapseWhitespace(child.text).trim().isNotEmpty; + final noteStyle = opensNote + ? _annotationStyle(defaultStyle, defaultStyle, note: true) + : null; + if (opensNote) spans.add(TextSpan(text: '[הערה: ', style: noteStyle)); _appendHtmlSpans( child, style: !opens @@ -105,15 +127,33 @@ class SnippetBuilder { : tag == 'mark' ? markStyle : highlightStyle, + defaultStyle: defaultStyle, spans: spans, highlightStyle: highlightStyle, markStyle: markStyle, highlighted: highlighted || opens, + inNote: inNote || opensNote, + inMarker: inMarker || tag == 'otzaria-note-marker', ); + if (opensNote) spans.add(TextSpan(text: ']', style: noteStyle)); } } } + static TextStyle _annotationStyle( + TextStyle style, + TextStyle defaultStyle, { + bool note = false, + bool marker = false, + }) { + if (!note && !marker) return style; + final size = style.fontSize ?? defaultStyle.fontSize; + return style.copyWith( + fontStyle: note ? FontStyle.italic : style.fontStyle, + fontSize: size == null ? null : size * (marker ? 0.75 : 0.9), + ); + } + /// מחלץ את המונחים שהמנוע סימן כהתאמות (תוכן תגי [_highlightTags]) מתוך /// [html]. משמש להדגשת ההתאמות האמיתיות על גבי דפי PDF. static Set extractHighlightedTerms(String html) { @@ -191,15 +231,32 @@ class SnippetBuilder { return _collapseWhitespace(body?.text ?? '').trim(); } + /// טקסט ההעתקה עם תוויות הערה; null משאיר תוכן ישן במסלול ההעתקה שלו. + static String? annotatedPlainText(String html) { + if (!html.contains('otzaria-note') || + html_parser.parse(html).body?.querySelector('otzaria-note') == null) { + return null; + } + return TextSpan( + children: fromHighlightedHtml( + html: html, + defaultStyle: const TextStyle(), + highlightStyle: const TextStyle(), + ), + ).toPlainText().trim(); + } + /// בונה [InlineSpan] מטקסט גולמי [plainText] וטווחי הדגשה [ranges] /// (זוגות [start, end]). משמש להדגשה עקבית עם פאנל הקריאה בסרגל התוצאות. + /// [sourceHtml] משמר את סימוני ההערות רק כשהטקסט שבו זהה ל-[plainText]. static List spansFromRanges({ required String plainText, required List> ranges, required TextStyle defaultStyle, required TextStyle highlightStyle, + String? sourceHtml, }) { - if (plainText.isEmpty || ranges.isEmpty) { + if (plainText.isEmpty) { return [TextSpan(text: plainText, style: defaultStyle)]; } final spans = []; @@ -217,10 +274,7 @@ class SnippetBuilder { ); } spans.add( - TextSpan( - text: plainText.substring(start, end), - style: highlightStyle, - ), + TextSpan(text: plainText.substring(start, end), style: highlightStyle), ); position = end; } @@ -229,7 +283,128 @@ class SnippetBuilder { TextSpan(text: plainText.substring(position), style: defaultStyle), ); } - return spans; + if (sourceHtml == null || !sourceHtml.contains('otzaria-note')) { + return spans; + } + return _annotateRanges(sourceHtml, plainText, spans, defaultStyle); + } + + /// הטווחים נשארים בטקסט המנוע; תווית ההערה נוספת רק אחרי ההדגשה. + static List _annotateRanges( + String html, + String plain, + List spans, + TextStyle defaultStyle, + ) { + final body = html_parser.parse(_withLineBreakMarks(html)).body; + if (body == null) return spans; + final raw = StringBuffer(); + final annotations = <({int start, int end, bool marker})>[]; + void visit(dom.Node node, {bool inNote = false}) { + if (node is dom.Text) { + raw.write(node.text); + return; + } + final tag = node is dom.Element ? node.localName : null; + final note = tag == 'otzaria-note' && !inNote; + final marker = tag == 'otzaria-note-marker'; + final start = raw.length; + for (final child in node.nodes) { + visit(child, inNote: inNote || note); + } + if (note || marker) { + annotations.add((start: start, end: raw.length, marker: marker)); + } + } + + visit(body); + if (annotations.isEmpty) return spans; + + final source = raw.toString(); + final offsets = List.filled(source.length + 1, 0); + final normalized = StringBuffer(); + var previous = 0; + void appendLiteral(int end) { + final target = normalized.length; + for (var i = previous; i <= end; i++) { + offsets[i] = target + i - previous; + } + normalized.write(source.substring(previous, end)); + previous = end; + } + + final spaces = RegExp('\\s*$_lineBreakMark\\s*|\\s+'); + for (final match in spaces.allMatches(source)) { + appendLiteral(match.start); + normalized.write(match[0]!.contains(_lineBreakMark) ? '\n' : ' '); + for (var i = match.start + 1; i <= match.end; i++) { + offsets[i] = normalized.length; + } + previous = match.end; + } + appendLiteral(source.length); + final untrimmed = normalized.toString(); + // טקסט שונה, גם אם אורכו זהה, אינו בסיס בטוח להלבשת טווחי המקור. + if (untrimmed.trim() != plain) return spans; + final leading = untrimmed.length - untrimmed.trimLeft().length; + int mapped(int offset) => + (offsets[offset] - leading).clamp(0, plain.length); + final mappedAnnotations = [ + for (final item in annotations) + if (mapped(item.start) < mapped(item.end)) + ( + start: mapped(item.start), + end: mapped(item.end), + marker: item.marker, + ), + ]; + final boundaries = {0, plain.length}; + final styled = <({int end, TextStyle style})>[]; + var position = 0; + for (final span in spans.cast()) { + position += span.text!.length; + boundaries.add(position); + styled.add((end: position, style: span.style!)); + } + for (final item in mappedAnnotations) { + boundaries.addAll([item.start, item.end]); + } + final points = boundaries.toList()..sort(); + final result = []; + final noteStyle = _annotationStyle(defaultStyle, defaultStyle, note: true); + var styleIndex = 0; + for (var i = 0; i < points.length; i++) { + final start = points[i]; + for (final item in mappedAnnotations) { + if (!item.marker && item.end == start) { + result.add(TextSpan(text: ']', style: noteStyle)); + } + } + for (final item in mappedAnnotations) { + if (!item.marker && item.start == start) { + result.add(TextSpan(text: '[הערה: ', style: noteStyle)); + } + } + if (i == points.length - 1) break; + while (styled[styleIndex].end <= start) { + styleIndex++; + } + final active = mappedAnnotations.where( + (item) => item.start <= start && item.end > start, + ); + result.add( + TextSpan( + text: plain.substring(start, points[i + 1]), + style: _annotationStyle( + styled[styleIndex].style, + defaultStyle, + note: active.any((item) => !item.marker), + marker: active.any((item) => item.marker), + ), + ), + ); + } + return result; } /// מדגיש הופעות ליטרליות של [query] בטקסט מקומי [plainText]. @@ -278,10 +453,7 @@ class SnippetBuilder { } if (position < plainText.length) { spans.add( - TextSpan( - text: plainText.substring(position), - style: defaultStyle, - ), + TextSpan(text: plainText.substring(position), style: defaultStyle), ); } return spans; diff --git a/lib/semantic_search/models/semantic_feedback_snapshots.dart b/lib/semantic_search/models/semantic_feedback_snapshots.dart index 6142bdb979..938501a134 100644 --- a/lib/semantic_search/models/semantic_feedback_snapshots.dart +++ b/lib/semantic_search/models/semantic_feedback_snapshots.dart @@ -21,7 +21,7 @@ import 'semantic_result_item.dart'; if (span is! TextSpan) continue; final text = span.text ?? ''; plain.write(text); - final isMark = identical(span.style, markStyle); + final isMark = span.style?.fontWeight == markStyle.fontWeight; if (isMark && inMark) { matched.last += text; } else if (isMark) { diff --git a/lib/semantic_search/view/semantic_search_results_screen.dart b/lib/semantic_search/view/semantic_search_results_screen.dart index f5db3eff3b..0f4ad15f5b 100644 --- a/lib/semantic_search/view/semantic_search_results_screen.dart +++ b/lib/semantic_search/view/semantic_search_results_screen.dart @@ -194,10 +194,7 @@ class _SemanticSearchResultsScreenState void _toggleDimension(String facet) { final dimensions = FacetHelper.dimensionFacetsOf(_currentFacets); if (!dimensions.remove(facet)) dimensions.add(facet); - _narrow( - FacetHelper.categoryFacetsOf(_currentFacets), - dimensions..sort(), - ); + _narrow(FacetHelper.categoryFacetsOf(_currentFacets), dimensions..sort()); } /// ספירה לפי קטגוריה של התוצאות שמוצגות כעת. @@ -443,7 +440,9 @@ class _SemanticSearchResultsScreenState String ref, ) { final plainText = CopyUtils.applyCopyPreferences( - text: utils.stripHtmlIfNeeded(snippetHtml), + text: + SnippetBuilder.annotatedPlainText(snippetHtml) ?? + utils.stripHtmlIfNeeded(snippetHtml), replaceHolyNames: settings.replaceHolyNames, holyNameStyle: settings.holyNameStyle, ); diff --git a/lib/text_book/view/text_book_search_screen.dart b/lib/text_book/view/text_book_search_screen.dart index 9d5e91f3d8..ac16edb0de 100644 --- a/lib/text_book/view/text_book_search_screen.dart +++ b/lib/text_book/view/text_book_search_screen.dart @@ -1104,6 +1104,7 @@ class TextBookSearchViewState extends State ranges: ranges, defaultStyle: defaultStyle, highlightStyle: highlightStyle, + sourceHtml: snippet, ); } diff --git a/test/search/snippet_note_annotations_engine_test.dart b/test/search/snippet_note_annotations_engine_test.dart new file mode 100644 index 0000000000..f30427fa6d --- /dev/null +++ b/test/search/snippet_note_annotations_engine_test.dart @@ -0,0 +1,111 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:otzaria/search/in_book_search_settings.dart'; +import 'package:otzaria/search/search_engine_gateway.dart'; +import 'package:otzaria/search/search_repository.dart'; +import 'package:otzaria/search/utils/snippet_builder.dart'; +import 'package:otzaria_search_engine/otzaria_search_engine.dart'; + +import '../support/search_engine_test_init.dart'; + +Future main() async { + final ready = await tryInitSearchEngine(); + final mode = Platform.environment['OTZARIA_EXPECT_NOTE_ANNOTATIONS'] ?? '0'; + final expectAnnotations = mode == '1'; + const topic = '/books/note-annotation-3292'; + const path = '/notes-3292-fixture.txt'; + // קטע סינתטי; ספר זה אינו מתחזה לפסקה המקורית שבמסד הספרים. + const source = + 'גוף12' + 'מפורשת סוף'; + late Directory directory; + late SearchEngine engine; + late SearchRepository repository; + + setUpAll(() async { + expect(mode, isIn(['0', '1'])); + if (!ready) return; + directory = await Directory.systemTemp.createTemp('snippet-note-3292-'); + engine = await SearchEngine.newInstance(path: directory.path); + await engine.addTextBook( + title: 'ספר בדיקת הערות', + topics: topic, + filePath: path, + text: source, + textStorage: TextStorage.inIndex, + ); + await engine.commit(); + repository = SearchRepository( + engineProvider: () async => RustSearchEngineOperations(engine), + ); + }); + + tearDownAll(() async { + if (!ready) return; + engine.dispose(); + if (!Platform.isWindows) await directory.delete(recursive: true); + }); + + for (final inBook in [false, true]) { + for (final query in ['גוף', 'מפורשת']) { + test('הערות native ${inBook ? 'בספר' : 'כללי'}: $query', () async { + final results = inBook + ? await searchBookWithEngine( + repository, + query: query, + bookPath: topic, + limit: 10, + settings: const InBookSearchSettings(distance: 0), + ) + : await repository.searchTexts( + SearchEngineRequest( + query: query, + facets: const ['/'], + limit: 10, + ), + ); + expect(results, hasLength(1)); + final result = results.single; + expect(result.filePath, path); + expect(result.textStatus, TextStatus.ok); + expect(result.text.contains(''), expectAnnotations); + expect( + result.text.contains(''), + expectAnnotations, + ); + expect( + SnippetBuilder.htmlToPlainText(result.text), + 'גוף 12 מפורשת סוף', + ); + final spans = SnippetBuilder.fromHighlightedHtml( + html: result.text, + defaultStyle: const TextStyle(fontSize: 20), + highlightStyle: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + ), + ).cast(); + expect( + spans.map((span) => span.text).join(), + expectAnnotations ? 'גוף 12 [הערה: מפורשת] סוף' : 'גוף 12 מפורשת סוף', + ); + final matched = spans + .where((span) => span.style?.fontWeight == FontWeight.bold) + .toList(); + expect(matched.map((span) => span.text).join(), query); + expect( + matched.every((span) => span.style?.fontStyle == FontStyle.italic), + expectAnnotations && query == 'מפורשת', + ); + if (expectAnnotations) { + expect( + spans.singleWhere((span) => span.text == '12').style!.fontSize, + 15, + ); + } + }, skip: ready ? false : searchEngineSkipReason); + } + } +} diff --git a/test/search/snippet_note_annotations_test.dart b/test/search/snippet_note_annotations_test.dart new file mode 100644 index 0000000000..683107b981 --- /dev/null +++ b/test/search/snippet_note_annotations_test.dart @@ -0,0 +1,345 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:otzaria/search/utils/snippet_builder.dart'; + +const _body = TextStyle(fontSize: 20, color: Colors.black); +const _match = TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Colors.red, +); + +List _html(String html, {TextStyle? markStyle}) => + SnippetBuilder.fromHighlightedHtml( + html: html, + defaultStyle: _body, + highlightStyle: _match, + markStyle: markStyle, + ).cast(); + +String _text(Iterable spans) => + spans.map((span) => span.text ?? '').join(); + +String _matched(Iterable spans) => + _text(spans.where((span) => span.style?.fontWeight == FontWeight.bold)); + +List _ranges( + String html, + List> ranges, { + String? plainText, +}) => SnippetBuilder.spansFromRanges( + plainText: plainText ?? SnippetBuilder.htmlToPlainText(html), + ranges: ranges, + defaultStyle: _body, + highlightStyle: _match, + sourceHtml: html, +).cast(); + +void main() { + group('תגיות הערה בתוצאת מנוע', () { + test('גוף ההערה מסומן במפורש והסמן מוקטן', () { + final spans = _html( + 'גוף 12 ' + 'דברי ההערה המשך', + ); + expect(_text(spans), 'גוף 12 [הערה: דברי ההערה] המשך'); + final note = spans.singleWhere((span) => span.text == 'דברי ההערה'); + expect(note.style!.fontStyle, FontStyle.italic); + expect(note.style!.fontSize, 18); + final marker = spans.singleWhere((span) => span.text == '12'); + expect(marker.style!.fontSize, 15); + expect(marker.style!.fontStyle, isNull); + expect(spans.first.style, same(_body)); + expect(spans.last.style, same(_body)); + }); + + test('התאמה רק בהערה נשארת מודגשת בלי להדגיש את התווית', () { + final spans = _html( + 'חכמה חכמה חכמה', + ); + expect(_text(spans), 'חכמה [הערה: חכמה] חכמה'); + expect(_matched(spans), 'חכמה'); + final match = spans.singleWhere( + (span) => span.style?.color == Colors.red, + ); + expect(match.style!.fontStyle, FontStyle.italic); + expect(match.style!.fontSize, closeTo(19.8, 0.0001)); + expect( + spans + .where((span) => span.text == '[הערה: ' || span.text == ']') + .every((span) => span.style!.fontWeight != FontWeight.bold), + isTrue, + ); + }); + + test('התאמה בגוף הספר אינה הופכת להערה', () { + final spans = _html( + 'חכמה חכמה המשך', + ); + expect(_matched(spans), 'חכמה'); + expect(spans.first.style, same(_match)); + expect(spans.first.style!.fontStyle, isNull); + expect( + spans + .singleWhere((span) => span.text == 'חכמה' && span != spans.first) + .style! + .fontStyle, + FontStyle.italic, + ); + }); + + test('סמן שמכיל התאמה שומר על הצבע וההדגשה', () { + final spans = _html( + '12', + ); + expect(_matched(spans), '12'); + expect(spans.single.style!.fontSize, 16.5); + expect(spans.single.style!.color, Colors.red); + }); + + test('הדגשת קטע סמנטי נשמרת בתוך הערה', () { + const markStyle = TextStyle(fontSize: 20, backgroundColor: Colors.yellow); + final spans = _html( + '…דברי ההערה…', + markStyle: markStyle, + ); + expect(_text(spans), '…[הערה: דברי ההערה]…'); + final note = spans.singleWhere((span) => span.text == 'דברי ההערה'); + expect(note.style!.backgroundColor, Colors.yellow); + expect(note.style!.fontStyle, FontStyle.italic); + expect(note.style!.fontSize, 18); + expect(spans.first.style, same(_body)); + expect(spans.last.style, same(_body)); + }); + + test('תג הדגשה חיצוני נשמר גם סביב גבול הערה', () { + final spans = _html( + 'גוף הערה סוף', + ); + expect(_matched(spans), 'גוף הערה סוף'); + expect(_text(spans), 'גוף [הערה: הערה] סוף'); + expect(spans.first.style, same(_match)); + expect(spans.last.style, same(_match)); + }); + + test('תגיות עיצוב רגילות אינן מוסבות להערות', () { + final spans = _html('גוף12נטוימודגש סוף'); + expect(_text(spans), 'גוף12נטוימודגש סוף'); + expect(spans.every((span) => identical(span.style, _body)), isTrue); + }); + + test('תגיות מוברחות נשארות תוכן רגיל', () { + final spans = _html('<otzaria-note>טקסט</otzaria-note>'); + expect(_text(spans), 'טקסט'); + expect(spans.single.style, same(_body)); + }); + + test('HTML ישן בלי תגיות הערה שומר על סגנונותיו המקוריים', () { + final spans = _html('גוף 12 מפורשת סוף'); + expect(_text(spans), 'גוף 12 מפורשת סוף'); + expect(_matched(spans), 'מפורשת'); + expect(spans[0].style, same(_body)); + expect(spans[1].style, same(_match)); + expect(spans[2].style, same(_body)); + }); + + test('החילוץ הגולמי וההתאמות אינם כוללים תוויות שנוספו לתצוגה', () { + const html = + ' גוף 12 ' + 'דבר מפורש
נוסף
סוף '; + expect( + SnippetBuilder.htmlToPlainText(html), + 'גוף 12 דבר מפורש\nנוסף סוף', + ); + expect(SnippetBuilder.extractHighlightedTerms(html), {'מפורש'}); + }); + + test('הערה ריקה אינה מוסיפה תווית לתוצאה', () { + expect(_text(_html('גוף סוף')), 'גוף סוף'); + }); + + test('העתקת הערה שומרת את התווית ואת מעבר השורה', () { + expect( + SnippetBuilder.annotatedPlainText( + 'גוף 12 ' + 'דבר
נוסף & אחר
סוף', + ), + 'גוף 12 [הערה: דבר\nנוסף & אחר] סוף', + ); + }); + + test('העתקת תוצאה ישנה נשארת בפענוח הקיים של הקורא', () { + expect(SnippetBuilder.annotatedPlainText('

גוף

סוף

'), isNull); + expect( + SnippetBuilder.annotatedPlainText('גוף 12 הערה סוף'), + isNull, + ); + }); + + test('טקסט מוברח או attribute אינם מפעילים העתקת הערה', () { + expect( + SnippetBuilder.annotatedPlainText( + '<otzaria-note>טקסט</otzaria-note>', + ), + isNull, + ); + expect( + SnippetBuilder.annotatedPlainText( + 'גוף', + ), + isNull, + ); + }); + }); + + group('הערות אחרי חישוב טווחי הדגשה מחדש', () { + const repeated = 'אב אב אב'; + + test('מילה חוזרת ממופה לפי מיקומה בתוך התג', () { + final spans = _ranges(repeated, [ + [3, 5], + ]); + expect(_text(spans), 'אב [הערה: אב] אב'); + expect(_matched(spans), 'אב'); + final match = spans.singleWhere( + (span) => span.style?.fontWeight == FontWeight.bold, + ); + expect(match.style!.fontStyle, FontStyle.italic); + expect(spans.first.style, same(_body)); + expect(spans.last.style, same(_body)); + }); + + test('הופעת אותה מילה אחרי ההערה נשארת חלק מהגוף', () { + final spans = _ranges(repeated, [ + [6, 8], + ]); + expect(_matched(spans), 'אב'); + expect(spans.last.style, same(_match)); + expect(spans.last.style!.fontStyle, isNull); + }); + + test('טווח שחוצה את גבולות ההערה אינו צובע את התווית', () { + final spans = _ranges(repeated, [ + [0, 8], + ]); + expect(_text(spans), 'אב [הערה: אב] אב'); + expect(_matched(spans), 'אב אב אב'); + expect( + spans + .where((span) => span.text == '[הערה: ' || span.text == ']') + .every((span) => span.style!.fontWeight != FontWeight.bold), + isTrue, + ); + }); + + test('רשימת טווחים ריקה עדיין מציגה את ההערה', () { + final spans = _ranges(repeated, []); + expect(_text(spans), 'אב [הערה: אב] אב'); + expect(_matched(spans), isEmpty); + }); + + test('טקסט שונה באותו אורך אינו מקבל את עיצוב המקור', () { + final spans = _ranges(repeated, [ + [3, 5], + ], plainText: 'גד גד גד'); + expect(_text(spans), 'גד גד גד'); + expect(_matched(spans), 'גד'); + expect( + spans.every((span) => span.style!.fontStyle != FontStyle.italic), + isTrue, + ); + }); + + test('גם תת־מחרוזת חוזרת אינה מזוהה בטעות עם ההערה', () { + final spans = _ranges(repeated, [ + [0, 2], + ], plainText: 'אב'); + expect(_text(spans), 'אב'); + expect(spans.single.style, same(_match)); + }); + + test('ישויות HTML ותווים מחוץ ל־BMP אינם מזיזים טווחים', () { + const html = '😀 & אב אב סוף'; + final plain = SnippetBuilder.htmlToPlainText(html); + final start = plain.lastIndexOf('אב'); + final spans = _ranges(html, [ + [start, start + 2], + ]); + expect(_text(spans), '😀 & אב [הערה: אב] סוף'); + expect(_matched(spans), 'אב'); + expect( + spans + .singleWhere((span) => span.style?.fontWeight == FontWeight.bold) + .style! + .fontStyle, + FontStyle.italic, + ); + }); + + test('כיווץ רווחים ומעברי שורה תואם לטקסט שעליו חושבו הטווחים', () { + const html = + ' גוף\t 12 ' + ' אב אב
אב
סוף '; + final plain = SnippetBuilder.htmlToPlainText(html); + final last = plain.lastIndexOf('אב'); + final spans = _ranges(html, [ + [last, last + 2], + ]); + expect(_text(spans).replaceAll('[הערה: ', '').replaceAll(']', ''), plain); + expect(_text(spans), contains('[הערה: ')); + expect(_matched(spans), 'אב'); + expect( + spans + .singleWhere((span) => span.style?.fontWeight == FontWeight.bold) + .style! + .fontStyle, + FontStyle.italic, + ); + expect(_text(spans), contains('\n')); + }); + + test('סמן מוקטן גם כשהוא עצמו התאמה', () { + final spans = _ranges( + 'גוף 12 סוף', + [ + [4, 6], + ], + ); + expect(_text(spans), 'גוף 12 סוף'); + final marker = spans.singleWhere((span) => span.text == '12'); + expect(marker.style!.fontWeight, FontWeight.bold); + expect(marker.style!.fontSize, 16.5); + }); + + test('שתי הערות עם אותו טקסט שומרות על זהויותיהן', () { + const html = + 'אב אב אב'; + final spans = _ranges(html, [ + [6, 8], + ]); + expect(_text(spans), '[הערה: אב] אב [הערה: אב]'); + expect(_matched(spans), 'אב'); + final notes = spans.where((span) => span.text == 'אב').toList(); + expect(notes, hasLength(2)); + expect(notes.first.style!.fontWeight, isNull); + expect(notes.last.style!.fontWeight, FontWeight.bold); + }); + + test('טווח חורג אינו משבש את גבולות ההערה', () { + final spans = _ranges(repeated, [ + [0, 99], + ]); + expect(_text(spans), 'אב [הערה: אב] אב'); + expect(_matched(spans), isEmpty); + }); + + test('טקסט ישן עם תגיות עיצוב רגילות שומר על סגנון הטווח', () { + final spans = _ranges('אב אב אב', [ + [3, 5], + ]); + expect(_text(spans), 'אב אב אב'); + expect(_matched(spans), 'אב'); + expect(spans[1].style, same(_match)); + }); + }); +} diff --git a/test/search/tantivy_search_results_test.dart b/test/search/tantivy_search_results_test.dart index bfa7d8b3f6..ecd2d648e0 100644 --- a/test/search/tantivy_search_results_test.dart +++ b/test/search/tantivy_search_results_test.dart @@ -180,9 +180,7 @@ void main() { ); } - testWidgets('מציג מקטע ראשון בחיפוש חדש לפני סיום הטעינה', ( - tester, - ) async { + testWidgets('מציג מקטע ראשון בחיפוש חדש לפני סיום הטעינה', (tester) async { await tester.pumpWidget(buildWidget()); await tester.pump(); final results = searchBloc.state.results.take(1).toList(); @@ -453,6 +451,59 @@ void main() { expect(copiedText, contains('HTML')); }); + testWidgets('כרטיס כללי מציג ומעתיק הערה בנפרד מגוף הספר', (tester) async { + String? copiedText; + tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + SystemChannels.platform, + (call) async { + if (call.method == 'Clipboard.setData') { + copiedText = (call.arguments as Map)['text'] as String?; + } + return null; + }, + ); + addTearDown( + () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + SystemChannels.platform, + null, + ), + ); + searchBloc.emitState( + searchBloc.state.copyWith( + totalResults: 1, + results: [ + SearchResult( + id: BigInt.one, + title: 'ספר בדיקת הערות', + reference: 'פרק א', + text: + 'גוף 12 ' + 'מפורשת סוף', + segment: BigInt.zero, + isPdf: false, + filePath: 'notes-fixture.txt', + mergedCount: 1, + merged: const [], + textStatus: TextStatus.ok, + continuesToNextLine: false, + ), + ], + ), + ); + await tester.pumpWidget(buildWidget()); + await tester.pump(); + final rendered = tester + .widgetList(find.byType(RichText)) + .singleWhere( + (widget) => widget.text.toPlainText().startsWith('גוף 12'), + ); + expect(rendered.text.toPlainText(), 'גוף 12 [הערה: מפורשת] סוף'); + expect(_highlightedTextFromInlineSpan(rendered.text), 'מפורשת'); + await tester.tap(find.byTooltip('העתק טקסט')); + await tester.pump(); + expect(copiedText, 'גוף 12 [הערה: מפורשת] סוף'); + }); + testWidgets('מציג הדגשת HTML שמגיעה ממנוע החיפוש', (tester) async { await tester.pumpWidget(buildWidget()); await tester.pump(); diff --git a/test/semantic_search/semantic_mode_gate_test.dart b/test/semantic_search/semantic_mode_gate_test.dart index a44a34d99b..9e305f9a7b 100644 --- a/test/semantic_search/semantic_mode_gate_test.dart +++ b/test/semantic_search/semantic_mode_gate_test.dart @@ -39,9 +39,7 @@ void main() { group('תצוגה מקדימה בפיתוח', () { test('דורשת פיתוח והסכמה, וחסרים מנוע או נתונים', () { - final missing = _availability( - SemanticAvailabilityPhase.needsDownload, - ); + final missing = _availability(SemanticAvailabilityPhase.needsDownload); final hidden = _availability( SemanticAvailabilityPhase.hidden, hiddenReason: SemanticHiddenReason.engineNotInBuild, @@ -172,6 +170,32 @@ void main() { expect(text.plain, 'כבד את אביך & אמך'); expect(text.matched, isEmpty); }); + + test('התאמה בהערה נשמרת גם אחרי התאמת הסגנון שלה', () { + final text = semanticSnippetText( + 'גוף 12 ' + 'דבר מפורש סוף', + ); + expect(text.plain, 'גוף 12 [הערה: דבר מפורש] סוף'); + expect(text.matched, ['מפורש']); + }); + + test('סמן מודגש וקטע סמנטי בהערה נשמרים בסנאפשוט', () { + final text = semanticSnippetText( + '12 ' + 'דבר מפורש', + ); + expect(text.plain, '12 [הערה: דבר מפורש]'); + expect(text.matched, ['12', 'דבר מפורש']); + }); + + test('תווית ההערה אינה התאמה בפני עצמה', () { + final text = semanticSnippetText( + 'גוף דבר מפורש סוף', + ); + expect(text.plain, 'גוף [הערה: דבר מפורש] סוף'); + expect(text.matched, isEmpty); + }); }); group('פרטיות התשובה', () { diff --git a/test/semantic_search/semantic_results_screen_test.dart b/test/semantic_search/semantic_results_screen_test.dart index e215bf2b51..214178068c 100644 --- a/test/semantic_search/semantic_results_screen_test.dart +++ b/test/semantic_search/semantic_results_screen_test.dart @@ -598,6 +598,53 @@ void main() { await tester.pump(const Duration(seconds: 7)); }); + testWidgets('כרטיס חכם מציג ומעתיק תווית הערה עם התאמה בתוכה', ( + tester, + ) async { + String? copied; + tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + SystemChannels.platform, + (call) async { + if (call.method == 'Clipboard.setData') { + copied = (call.arguments as Map)['text'] as String?; + } + return null; + }, + ); + addTearDown( + () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + SystemChannels.platform, + null, + ), + ); + final source = FakeResultsSource( + items: [ + resultItem( + 1, + source: SemanticResultSource.lexical, + html: + 'גוף 12 ' + 'מפורשת סוף', + ), + ], + ); + await pumpScreen(tester, injectedSource: source); + final card = tester.widget( + find.byKey(const ValueKey('semantic-result-0')), + ); + final spans = card.snippetSpans.cast(); + expect(spans.map((span) => span.text).join(), 'גוף 12 [הערה: מפורשת] סוף'); + final highlighted = spans.singleWhere( + (span) => span.style?.fontWeight == FontWeight.bold, + ); + expect(highlighted.text, 'מפורשת'); + expect(highlighted.style!.fontStyle, FontStyle.italic); + card.onCopy(); + await settle(tester); + expect(copied, 'גוף 12 [הערה: מפורשת] סוף'); + await tester.pump(const Duration(seconds: 7)); + }); + group('העתקה מחליפה שמות קודש לפי ההגדרה (issue #3954)', () { // השם בן ארבע האותיות נבנה מקודי תווים, כדי שלא ייכתב בקובץ. final name = String.fromCharCodes(const [0x05D9, 0x05D4, 0x05D5, 0x05D4]); @@ -639,13 +686,10 @@ void main() { ]; // הרביעי מוצג מהקטע שסומן לפי עניין, לא מהגזיר. final source = FakeResultsSource(items: items) - ..highlighter = (items, _) async => markAll( - [ - for (final item in items) - if (item.segment == 4) item, - ], - clause: name, - ); + ..highlighter = (items, _) async => markAll([ + for (final item in items) + if (item.segment == 4) item, + ], clause: name); await pumpScreen( tester, injectedSource: source, @@ -845,9 +889,7 @@ void main() { expect(find.text('ספר 1, א'), findsOneWidget); expect(harness.recorder.searches, hasLength(1)); }); - testWidgets('תצוגה מקדימה מושהית מתבטלת כשהחיפוש מתחלף', ( - tester, - ) async { + testWidgets('תצוגה מקדימה מושהית מתבטלת כשהחיפוש מתחלף', (tester) async { tester.view.physicalSize = const Size(1000, 900); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -884,9 +926,7 @@ void main() { ); }); - testWidgets('פתיחה מושהית אינה מיוחסת לתוצאה מהחיפוש החדש', ( - tester, - ) async { + testWidgets('פתיחה מושהית אינה מיוחסת לתוצאה מהחיפוש החדש', (tester) async { final items = [resultItem(1), resultItem(2)]; final source = FakeResultsSource(items: items); final harness = await pumpScreen(tester, injectedSource: source); @@ -946,9 +986,7 @@ void main() { expect(harness.source.fetches, hasLength(3)); expect(harness.recorder.shown.map((page) => page.offset), [0, 30]); }); - testWidgets('רשימה גדולה בונה רק כרטיסים הנראים במסך', ( - tester, - ) async { + testWidgets('רשימה גדולה בונה רק כרטיסים הנראים במסך', (tester) async { final harness = await pumpScreen( tester, injectedSource: FakeResultsSource(total: 10000), @@ -959,20 +997,19 @@ void main() { expect(harness.source.fetches, hasLength(1)); }); - testWidgets( - 'חלונית desktop ברוחב 300 מציגה את הכרטיסים ללא גלישה', - (tester) async { - tester.view.physicalSize = const Size(1000, 900); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - final loader = FontLoader('Roboto') - ..addFont(rootBundle.load('fonts/Rubik-VariableFont_wght.ttf')); - await loader.load(); - await pumpScreen(tester, paneWidth: 300); - expect(tester.takeException(), isNull); - }, - ); + testWidgets('חלונית desktop ברוחב 300 מציגה את הכרטיסים ללא גלישה', ( + tester, + ) async { + tester.view.physicalSize = const Size(1000, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + final loader = FontLoader('Roboto') + ..addFont(rootBundle.load('fonts/Rubik-VariableFont_wght.ttf')); + await loader.load(); + await pumpScreen(tester, paneWidth: 300); + expect(tester.takeException(), isNull); + }); testWidgets('הסרגל מציג את מספר התוצאות שמוצגות כעת', (tester) async { tester.view.physicalSize = const Size(1200, 900); @@ -985,10 +1022,7 @@ void main() { tester.widget(find.byType(SearchTermsDisplay)).query, 'כבוד אב', ); - expect( - find.textContaining('כבוד', findRichText: true), - findsWidgets, - ); + expect(find.textContaining('כבוד', findRichText: true), findsWidgets); expect(find.byKey(const ValueKey('semantic-results-query')), findsNothing); }); diff --git a/test/text_book/view/text_book_search_engine_route_test.dart b/test/text_book/view/text_book_search_engine_route_test.dart index cb33602c1b..ebb57fa3c5 100644 --- a/test/text_book/view/text_book_search_engine_route_test.dart +++ b/test/text_book/view/text_book_search_engine_route_test.dart @@ -28,6 +28,7 @@ import 'package:otzaria_search_engine/otzaria_search_engine.dart'; import '../../support/search_engine_test_init.dart'; import '../../test_helpers/memory_cache_provider.dart'; + import 'package:otzaria/text_book/view/reading_viewport/line_scroll_controller.dart'; /// חלונית החיפוש בספר כשהשאילתה נושאת תוספות (מרווח בין מילים וכו'): @@ -149,44 +150,106 @@ Future main() async { ); } - testWidgets( - 'שאילתה עם מרווח בין מילים רצה במסלול המנוע ומציגה את התוצאות', - (tester) async { - // הרגרסיה: תוצאה שנפתחה מחיפוש "תדע זרעך" במרווח מילים הגיעה לספר - // כשאילתה מדויקת במרווח 0, החיפוש המקומי חיפש מחרוזת רצופה, והחלונית - // הציגה "אין תוצאות". + testWidgets('שאילתה עם מרווח בין מילים רצה במסלול המנוע ומציגה את התוצאות', ( + tester, + ) async { + // הרגרסיה: תוצאה שנפתחה מחיפוש "תדע זרעך" במרווח מילים הגיעה לספר + // כשאילתה מדויקת במרווח 0, החיפוש המקומי חיפש מחרוזת רצופה, והחלונית + // הציגה "אין תוצאות". + final repository = _RecordingSearchRepository( + results: [ + _result(title: 'בראשית', reference: 'בראשית, פרק טו', segment: 0), + ], + ); + var simpleRunnerCalls = 0; + + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע זרעך', + searchDistance: 3, + bookTitle: 'בראשית', + content: const ['ויאמר לאברם ידע תדע כי־גר יהיה זרעך בארץ לא להם'], + simpleSearchRunner: (content, query) async { + simpleRunnerCalls++; + return const []; + }, + ); + + await harness.settle(); + + expect(simpleRunnerCalls, 0, reason: 'אסור ליפול למסלול המחרוזת המקומי'); + expect(repository.requests, hasLength(1)); + expect(repository.requests.single.query, 'תדע זרעך'); + expect(repository.requests.single.distance, 3); + expect(find.text('אין תוצאות'), findsNothing); + expect(find.text('בראשית, פרק טו'), findsOneWidget); + expect(find.text('נמצאו 1 תוצאות'), findsOneWidget); + }, skip: !engineReady); + + for (final inNote in [false, true]) { + testWidgets('תוצאת מנוע שומרת גבול הערה אחרי חישוב טווחים: inNote=$inNote', ( + tester, + ) async { + const note = 'ורבותינו זל'; + const body = 'ואיתא בזוהר'; + final query = inNote ? note : body; + // קטע סינתטי עם מבנה ההערה שבדיווח #3292, ללא מסד הספרים האמיתי. + final html = + 'ראשית 12 ' + '${inNote ? '$note' : note} ' + '${inNote ? body : '$body'}'; final repository = _RecordingSearchRepository( results: [ - _result(title: 'בראשית', reference: 'בראשית, פרק טו', segment: 0), + _result( + title: 'ספר בדיקה', + reference: 'פרק בדיקה', + segment: 0, + text: html, + ), ], ); - var simpleRunnerCalls = 0; - + var simpleCalls = 0; final harness = await pumpSearchView( tester, searchRepository: repository, - initialQuery: 'תדע זרעך', - searchDistance: 3, - bookTitle: 'בראשית', - content: const ['ויאמר לאברם ידע תדע כי־גר יהיה זרעך בארץ לא להם'], - simpleSearchRunner: (content, query) async { - simpleRunnerCalls++; - return const []; + initialQuery: query, + searchDistance: 1, + content: const ['ראשית 12 ורבותינו זל ואיתא בזוהר'], + simpleSearchRunner: (_, _) async { + simpleCalls++; + return []; }, ); - await harness.settle(); - - expect(simpleRunnerCalls, 0, reason: 'אסור ליפול למסלול המחרוזת המקומי'); + expect(simpleCalls, 0); expect(repository.requests, hasLength(1)); - expect(repository.requests.single.query, 'תדע זרעך'); - expect(repository.requests.single.distance, 3); - expect(find.text('אין תוצאות'), findsNothing); - expect(find.text('בראשית, פרק טו'), findsOneWidget); - expect(find.text('נמצאו 1 תוצאות'), findsOneWidget); - }, - skip: !engineReady, - ); + expect(repository.requests.single.query, query); + final finder = find.byWidgetPredicate( + (widget) => + widget is RichText && + widget.text.toPlainText().contains('ראשית 12'), + ); + expect(finder, findsOneWidget); + final text = tester.widget(finder).text as TextSpan; + expect( + text.toPlainText(), + 'ראשית 12 [הערה: ורבותינו זל] ואיתא בזוהר', + reason: 'הערת המקור נשארת מובחנת אחרי חישוב ההדגשות מחדש', + ); + final spans = text.children!.cast(); + final matches = spans + .where((span) => span.style?.fontWeight == FontWeight.bold) + .toList(); + expect(matches.map((span) => span.text).toList(), query.split(' ')); + expect( + matches.map((span) => span.style?.fontStyle).toList(), + [for (final _ in query.split(' ')) inNote ? FontStyle.italic : null], + ); + final marker = spans.singleWhere((span) => span.text == '12'); + expect(marker.style!.fontSize, 12); + }, skip: engineReady ? false : searchEngineSkipReason); + } testWidgets('שאילתה חיצונית מעדכנת ניתוב בשני הכיוונים בלי שינוי בהגדרות', ( tester, @@ -268,112 +331,103 @@ Future main() async { } } - testWidgets( - 'שורה שהמנוע לא קרא מוצגת מתוכן הספר הטעון', - (tester) async { - final repository = _RecordingSearchRepository( - results: [ - _result( - title: 'בראשית', - reference: 'פרק טו', - segment: 0, - text: '', - textStatus: TextStatus.unavailable, - ), - _result( - title: 'בראשית', - reference: 'פרק טז', - segment: 1, - text: '', - textStatus: TextStatus.stale, - ), - ], - ); + testWidgets('שורה שהמנוע לא קרא מוצגת מתוכן הספר הטעון', (tester) async { + final repository = _RecordingSearchRepository( + results: [ + _result( + title: 'בראשית', + reference: 'פרק טו', + segment: 0, + text: '', + textStatus: TextStatus.unavailable, + ), + _result( + title: 'בראשית', + reference: 'פרק טז', + segment: 1, + text: '', + textStatus: TextStatus.stale, + ), + ], + ); - final harness = await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע זרעך', - searchDistance: 3, - bookTitle: 'בראשית', - content: const [ - 'ויאמר לאברם ידע תדע כי־גר יהיה זרעך', - 'שורה שנייה תדע את זרעך', - ], - ); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע זרעך', + searchDistance: 3, + bookTitle: 'בראשית', + content: const [ + 'ויאמר לאברם ידע תדע כי־גר יהיה זרעך', + 'שורה שנייה תדע את זרעך', + ], + ); - await harness.settle(); + await harness.settle(); - expect(find.text(unavailableResultText), findsNothing); - String resultText(String needle) => tester - .widgetList(find.byType(RichText)) - .map((widget) => widget.text.toPlainText()) - .singleWhere((text) => text.contains(needle)); - expect(resultText('לאברם'), 'ויאמר לאברם ידע תדע כי־גר יהיה זרעך'); - expect(resultText('שנייה'), 'שורה שנייה תדע את זרעך'); - }, - skip: !engineReady, - ); + expect(find.text(unavailableResultText), findsNothing); + String resultText(String needle) => tester + .widgetList(find.byType(RichText)) + .map((widget) => widget.text.toPlainText()) + .singleWhere((text) => text.contains(needle)); + expect(resultText('לאברם'), 'ויאמר לאברם ידע תדע כי־גר יהיה זרעך'); + expect(resultText('שנייה'), 'שורה שנייה תדע את זרעך'); + }, skip: !engineReady); - testWidgets( - 'קטע משורה ארוכה שהמנוע לא קרא נחתך סביב התאמה עם מרווח', - (tester) async { - final repository = _RecordingSearchRepository( - results: [ - _result( - title: 'בראשית', - reference: 'פרק טו', - segment: 0, - text: '', - textStatus: TextStatus.unavailable, - ), - ], - ); - final filler = List.filled(16, 'מילה אחרת בלי קשר').join(' '); + testWidgets('קטע משורה ארוכה שהמנוע לא קרא נחתך סביב התאמה עם מרווח', ( + tester, + ) async { + final repository = _RecordingSearchRepository( + results: [ + _result( + title: 'בראשית', + reference: 'פרק טו', + segment: 0, + text: '', + textStatus: TextStatus.unavailable, + ), + ], + ); + final filler = List.filled(16, 'מילה אחרת בלי קשר').join(' '); - final harness = await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע זרעך', - searchDistance: 3, - bookTitle: 'בראשית', - content: ['$filler ידע תדע כי גר יהיה זרעך בארץ'], - ); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע זרעך', + searchDistance: 3, + bookTitle: 'בראשית', + content: ['$filler ידע תדע כי גר יהיה זרעך בארץ'], + ); - await harness.settle(); + await harness.settle(); - final shown = tester - .widgetList(find.byType(RichText)) - .map((widget) => widget.text.toPlainText()) - .singleWhere((text) => text.contains('מילה אחרת')); - expect(shown, contains('תדע כי גר יהיה זרעך')); - expect(shown, startsWith('... ')); - }, - skip: !engineReady, - ); + final shown = tester + .widgetList(find.byType(RichText)) + .map((widget) => widget.text.toPlainText()) + .singleWhere((text) => text.contains('מילה אחרת')); + expect(shown, contains('תדע כי גר יהיה זרעך')); + expect(shown, startsWith('... ')); + }, skip: !engineReady); - testWidgets( - 'שאילתה בלי תוספות אינה פונה למנוע', - (tester) async { - final repository = _RecordingSearchRepository(results: const []); - var simpleRunnerCalls = 0; + testWidgets('שאילתה בלי תוספות אינה פונה למנוע', (tester) async { + final repository = _RecordingSearchRepository(results: const []); + var simpleRunnerCalls = 0; - final harness = await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע', - simpleSearchRunner: (content, query) async { - simpleRunnerCalls++; - return const []; - }, - ); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע', + simpleSearchRunner: (content, query) async { + simpleRunnerCalls++; + return const []; + }, + ); - await harness.settle(); + await harness.settle(); - expect(simpleRunnerCalls, greaterThan(0)); - expect(repository.requests, isEmpty); - }, - ); + expect(simpleRunnerCalls, greaterThan(0)); + expect(repository.requests, isEmpty); + }); group('ברירת המחדל השמורה חלה על חיפוש חדש בספר (issue #1937)', () { tearDown(() { @@ -514,27 +568,25 @@ Future main() async { skip: !engineReady, ); - testWidgets( - 'אפשרויות שנקבעו כברירת מחדל חלות על כל מילה בשאילתה שהוקלדה', - (tester) async { - SearchDefaults.saveExactDefaults(const {'קידומות דקדוקיות': true}); - final repository = _RecordingSearchRepository(results: const []); - final harness = await pumpSearchView( - tester, - searchRepository: repository, - ); + testWidgets('אפשרויות שנקבעו כברירת מחדל חלות על כל מילה בשאילתה שהוקלדה', ( + tester, + ) async { + SearchDefaults.saveExactDefaults(const {'קידומות דקדוקיות': true}); + final repository = _RecordingSearchRepository(results: const []); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + ); - await harness.type('תדע זרעך'); - await harness.settle(); + await harness.type('תדע זרעך'); + await harness.settle(); - expect(repository.requests, isNotEmpty); - expect(repository.requests.last.searchOptions, { - 'תדע_0': {'קידומות דקדוקיות': true}, - 'זרעך_1': {'קידומות דקדוקיות': true}, - }); - }, - skip: !engineReady, - ); + expect(repository.requests, isNotEmpty); + expect(repository.requests.last.searchOptions, { + 'תדע_0': {'קידומות דקדוקיות': true}, + 'זרעך_1': {'קידומות דקדוקיות': true}, + }); + }, skip: !engineReady); }); testWidgets('echo עם snapshot תבנית שווה אינו מפעיל חיפוש/אירוע נוסף', ( @@ -773,136 +825,122 @@ Future main() async { }, ); - testWidgets( - 'חיפוש מנוע ממתין לזיהוי הספר במקום להציג "אין תוצאות"', - (tester) async { - // זיהוי הספר (facet) הוא אסינכרוני. חיפוש שנשלח לפני שהסתיים היה - // מציג "אין תוצאות" ולא מנסה שוב. - final libraryCompleter = Completer(); - DataRepository.instance.library = libraryCompleter.future; + testWidgets('חיפוש מנוע ממתין לזיהוי הספר במקום להציג "אין תוצאות"', ( + tester, + ) async { + // זיהוי הספר (facet) הוא אסינכרוני. חיפוש שנשלח לפני שהסתיים היה + // מציג "אין תוצאות" ולא מנסה שוב. + final libraryCompleter = Completer(); + DataRepository.instance.library = libraryCompleter.future; - final repository = _RecordingSearchRepository( - results: [ - _result(title: 'ספר בדיקה', reference: 'קטע ב', segment: 0), - ], - ); + final repository = _RecordingSearchRepository( + results: [_result(title: 'ספר בדיקה', reference: 'קטע ב', segment: 0)], + ); - final harness = await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע זרעך', - searchDistance: 2, - ); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע זרעך', + searchDistance: 2, + ); - await harness.settle(); - expect( - repository.requests, - isEmpty, - reason: 'הזיהוי עדיין לא הסתיים — אין עוד מה לשלוח למנוע', - ); + await harness.settle(); + expect( + repository.requests, + isEmpty, + reason: 'הזיהוי עדיין לא הסתיים — אין עוד מה לשלוח למנוע', + ); - libraryCompleter.complete(Library(categories: const [])); - await harness.settle(); + libraryCompleter.complete(Library(categories: const [])); + await harness.settle(); - expect(repository.requests, hasLength(1)); - expect(find.text('קטע ב'), findsOneWidget); - expect(find.text('אין תוצאות'), findsNothing); - }, - skip: !engineReady, - ); + expect(repository.requests, hasLength(1)); + expect(find.text('קטע ב'), findsOneWidget); + expect(find.text('אין תוצאות'), findsNothing); + }, skip: !engineReady); - testWidgets( - 'טווח "באותה פסקה" והתאמה חלקית עוברים אל בקשת המנוע', - (tester) async { - // בלי העברת מדיניות ההתאמה, חיפוש שנמצא "באותה פסקה" היה מתורגם בספר - // לחיפוש מרווח-מילים ומחזיר תוצאות אחרות מאלה שהמשתמש ראה. - final repository = _RecordingSearchRepository( - results: [ - _result(title: 'ספר בדיקה', reference: 'קטע א', segment: 0), - ], - ); + testWidgets('טווח "באותה פסקה" והתאמה חלקית עוברים אל בקשת המנוע', ( + tester, + ) async { + // בלי העברת מדיניות ההתאמה, חיפוש שנמצא "באותה פסקה" היה מתורגם בספר + // לחיפוש מרווח-מילים ומחזיר תוצאות אחרות מאלה שהמשתמש ראה. + final repository = _RecordingSearchRepository( + results: [_result(title: 'ספר בדיקה', reference: 'קטע א', segment: 0)], + ); - final harness = await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע זרעך', - searchMode: SearchMode.advanced, - matchPolicy: const SearchMatchPolicy( - proximityScope: SearchScope.sameParagraph, - wordMatchMode: WordMatchMode.atLeast, - wordMatchCount: 2, - ), - ); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע זרעך', + searchMode: SearchMode.advanced, + matchPolicy: const SearchMatchPolicy( + proximityScope: SearchScope.sameParagraph, + wordMatchMode: WordMatchMode.atLeast, + wordMatchCount: 2, + ), + ); - await harness.settle(); + await harness.settle(); - expect(repository.requests, hasLength(1)); - final request = repository.requests.single; - expect(request.scope, SearchScope.sameParagraph); - expect(request.wordMatchMode, WordMatchMode.atLeast); - expect(request.wordMatchCount, 2); - expect(find.text('קטע א'), findsOneWidget); - }, - skip: !engineReady, - ); + expect(repository.requests, hasLength(1)); + final request = repository.requests.single; + expect(request.scope, SearchScope.sameParagraph); + expect(request.wordMatchMode, WordMatchMode.atLeast); + expect(request.wordMatchCount, 2); + expect(find.text('קטע א'), findsOneWidget); + }, skip: !engineReady); - testWidgets( - 'תוצאת מנוע מחוץ לחלון התוכן שנטען אינה נזרקת', - (tester) async { - // `state.content` הוא חלון חלקי סביב מקום הקריאה; תוצאה בשורה מאוחרת - // ממנו נזרקה בעבר בהמרה והחלונית הציגה "אין תוצאות". - final repository = _RecordingSearchRepository( - results: [ - _result(title: 'ספר בדיקה', reference: 'קטע רחוק', segment: 500), - ], - ); + testWidgets('תוצאת מנוע מחוץ לחלון התוכן שנטען אינה נזרקת', (tester) async { + // `state.content` הוא חלון חלקי סביב מקום הקריאה; תוצאה בשורה מאוחרת + // ממנו נזרקה בעבר בהמרה והחלונית הציגה "אין תוצאות". + final repository = _RecordingSearchRepository( + results: [ + _result(title: 'ספר בדיקה', reference: 'קטע רחוק', segment: 500), + ], + ); - final harness = await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע זרעך', - searchDistance: 2, - content: const ['שורה א'], - ); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע זרעך', + searchDistance: 2, + content: const ['שורה א'], + ); - await harness.settle(); + await harness.settle(); - expect(find.text('קטע רחוק'), findsOneWidget); - expect(find.text('אין תוצאות'), findsNothing); - }, - skip: !engineReady, - ); + expect(find.text('קטע רחוק'), findsOneWidget); + expect(find.text('אין תוצאות'), findsNothing); + }, skip: !engineReady); - testWidgets( - 'החלונית משדרת ל-BLoC את שורות התוצאות (בסיס ההדגשה במדיניות)', - (tester) async { - // ההכרעה מי שורת תוצאה נשארת אצל המנוע: החלונית מדווחת את השורות, - // והרינדור מדגיש מילה-מילה רק בהן. - final repository = _RecordingSearchRepository( - results: [ - _result(title: 'ספר בדיקה', reference: 'קטע א', segment: 3), - _result(title: 'ספר בדיקה', reference: 'קטע ב', segment: 17), - ], - ); + testWidgets('החלונית משדרת ל-BLoC את שורות התוצאות (בסיס ההדגשה במדיניות)', ( + tester, + ) async { + // ההכרעה מי שורת תוצאה נשארת אצל המנוע: החלונית מדווחת את השורות, + // והרינדור מדגיש מילה-מילה רק בהן. + final repository = _RecordingSearchRepository( + results: [ + _result(title: 'ספר בדיקה', reference: 'קטע א', segment: 3), + _result(title: 'ספר בדיקה', reference: 'קטע ב', segment: 17), + ], + ); - final harness = await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע זרעך', - searchMode: SearchMode.advanced, - matchPolicy: const SearchMatchPolicy( - proximityScope: SearchScope.sameSection, - ), - ); + final harness = await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע זרעך', + searchMode: SearchMode.advanced, + matchPolicy: const SearchMatchPolicy( + proximityScope: SearchScope.sameSection, + ), + ); - await harness.settle(); + await harness.settle(); - final reported = harness.bloc.reportedResultLines; - expect(reported, isNotEmpty); - expect(reported.last, {3, 17}); - }, - skip: !engineReady, - ); + final reported = harness.bloc.reportedResultLines; + expect(reported, isNotEmpty); + expect(reported.last, {3, 17}); + }, skip: !engineReady); testWidgets( 'חיפוש בלי תוצאות משדר קבוצה ריקה, ולא משאיר שורות מאושרות ישנות', @@ -1010,39 +1048,37 @@ Future main() async { } } - testWidgets( - 'תוצאת מנוע מנוקדת מוצגת לפי הגדרת הניקוד של הלשונית', - (tester) async { - final repository = _RecordingSearchRepository( - results: [ - _result( - title: 'בראשית', - reference: 'פרק טו', - segment: 0, - text: 'יָדֹ֨עַ תֵּדַ֜ע כִּי־גֵ֣ר', - ), - ], - ); + testWidgets('תוצאת מנוע מנוקדת מוצגת לפי הגדרת הניקוד של הלשונית', ( + tester, + ) async { + final repository = _RecordingSearchRepository( + results: [ + _result( + title: 'בראשית', + reference: 'פרק טו', + segment: 0, + text: 'יָדֹ֨עַ תֵּדַ֜ע כִּי־גֵ֣ר', + ), + ], + ); - await (await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: 'תדע כי', - searchDistance: 1, - bookTitle: 'בראשית', - content: const ['ידע תדע כי־גר'], - removeNikud: true, - )).settle(); - - final shown = tester - .widgetList(find.byType(RichText)) - .map((widget) => widget.text.toPlainText()) - .where((text) => text.contains('תדע')); - // כמו בספר: הסרת ניקוד וטעמים הופכת גם מקף לרווח. - expect(shown, ['ידע תדע כי גר']); - }, - skip: !engineReady, - ); + await (await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: 'תדע כי', + searchDistance: 1, + bookTitle: 'בראשית', + content: const ['ידע תדע כי־גר'], + removeNikud: true, + )).settle(); + + final shown = tester + .widgetList(find.byType(RichText)) + .map((widget) => widget.text.toPlainText()) + .where((text) => text.contains('תדע')); + // כמו בספר: הסרת ניקוד וטעמים הופכת גם מקף לרווח. + expect(shown, ['ידע תדע כי גר']); + }, skip: !engineReady); testWidgets( 'תוצאת מנוע שנמשכת לשורה הבאה נספרת פעם אחת ומסמנת את שתי השורות', @@ -1076,26 +1112,24 @@ Future main() async { skip: !engineReady, ); - testWidgets( - 'חיפוש מקומי מוצא ביטוי שנמשך לשורה הבאה ומסמן את שתי השורות', - (tester) async { - final harness = await pumpSearchView( - tester, - searchRepository: _RecordingSearchRepository(results: const []), - initialQuery: 'ובין המים ויאמר', - content: const [ - 'ויבדל בין המים אשר מתחת לרקיע ובין המים', - '(ג) ויאמר אלהים יקוו המים', - ], - ); + testWidgets('חיפוש מקומי מוצא ביטוי שנמשך לשורה הבאה ומסמן את שתי השורות', ( + tester, + ) async { + final harness = await pumpSearchView( + tester, + searchRepository: _RecordingSearchRepository(results: const []), + initialQuery: 'ובין המים ויאמר', + content: const [ + 'ויבדל בין המים אשר מתחת לרקיע ובין המים', + '(ג) ויאמר אלהים יקוו המים', + ], + ); - await harness.settle(); + await harness.settle(); - expect(find.text('נמצאו 1 תוצאות'), findsOneWidget); - expect(harness.bloc.reportedResultLines.last, {0, 1}); - }, - skip: !engineReady, - ); + expect(find.text('נמצאו 1 תוצאות'), findsOneWidget); + expect(harness.bloc.reportedResultLines.last, {0, 1}); + }, skip: !engineReady); testWidgets( 'כשל בזיהוי הספר מציג שגיאה, ואינו משאיר את החלונית במצב "מחפש"', @@ -1103,9 +1137,7 @@ Future main() async { // הספר עדיין נטען (ה-state אינו TextBookLoaded) ולכן אין ממה לבנות את // זיהוי הספר. לפני התיקון החלונית הציגה "אין תוצאות". final repository = _RecordingSearchRepository( - results: [ - _result(title: 'ספר בדיקה', reference: 'קטע א', segment: 0), - ], + results: [_result(title: 'ספר בדיקה', reference: 'קטע א', segment: 0)], ); final harness = await pumpSearchView( @@ -1140,30 +1172,28 @@ Future main() async { skip: !engineReady, ); - testWidgets( - '`/…/` רץ במתאם של המנוע על שורות הספר, גם כשיש תוספות', - (tester) async { - final repository = _RecordingSearchRepository(results: const []); - var simpleRunnerCalls = 0; + testWidgets('`/…/` רץ במתאם של המנוע על שורות הספר, גם כשיש תוספות', ( + tester, + ) async { + final repository = _RecordingSearchRepository(results: const []); + var simpleRunnerCalls = 0; - await pumpSearchView( - tester, - searchRepository: repository, - initialQuery: '/מו?שה/', - searchDistance: 3, - content: const ['ויאמר משה אל מושה', 'ומשהו אחר'], - simpleSearchRunner: (content, query) async { - simpleRunnerCalls++; - return const []; - }, - ).then((harness) => harness.settle()); + await pumpSearchView( + tester, + searchRepository: repository, + initialQuery: '/מו?שה/', + searchDistance: 3, + content: const ['ויאמר משה אל מושה', 'ומשהו אחר'], + simpleSearchRunner: (content, query) async { + simpleRunnerCalls++; + return const []; + }, + ).then((harness) => harness.settle()); - expect(simpleRunnerCalls, 0); - expect(repository.requests, isEmpty); - expect(find.text('נמצאו 2 תוצאות'), findsOneWidget); - }, - skip: !engineReady, - ); + expect(simpleRunnerCalls, 0); + expect(repository.requests, isEmpty); + expect(find.text('נמצאו 2 תוצאות'), findsOneWidget); + }, skip: !engineReady); } class _Harness { From 05b85cc75480e9b4ca880074d2ee1f6215a4c512 Mon Sep 17 00:00:00 2001 From: palmoni5 Date: Fri, 13 Nov 2026 01:35:08 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=D7=91=D7=93=D7=99=D7=A7=D7=95=D7=AA:=20?= =?UTF-8?q?=D7=93=D7=99=D7=9C=D7=95=D7=92=20=D7=91=D7=95=D7=9C=D7=99=D7=90?= =?UTF-8?q?=D7=A0=D7=99=20=D7=91=D7=91=D7=93=D7=99=D7=A7=D7=AA=20=D7=95?= =?UTF-8?q?=D7=95=D7=99=D7=93=D7=92'=D7=98=20=D7=94=D7=94=D7=A2=D7=A8?= =?UTF-8?q?=D7=95=D7=AA=20=D7=91=D7=97=D7=99=D7=A4=D7=95=D7=A9=20=D7=91?= =?UTF-8?q?=D7=A1=D7=A4=D7=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit בדיקת סמן ההערה במסלול המנוע של החיפוש בספר משתמשת ב-skip: !engineReady במקום ביטוי שמחזיר false או מחרוזת סיבה. ההתנהגות זהה: הבדיקה רצה כשהמנוע זמין ומדלגת כשהוא חסר. --- test/text_book/view/text_book_search_engine_route_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/text_book/view/text_book_search_engine_route_test.dart b/test/text_book/view/text_book_search_engine_route_test.dart index ebb57fa3c5..07f182060e 100644 --- a/test/text_book/view/text_book_search_engine_route_test.dart +++ b/test/text_book/view/text_book_search_engine_route_test.dart @@ -248,7 +248,7 @@ Future main() async { ); final marker = spans.singleWhere((span) => span.text == '12'); expect(marker.style!.fontSize, 12); - }, skip: engineReady ? false : searchEngineSkipReason); + }, skip: !engineReady); } testWidgets('שאילתה חיצונית מעדכנת ניתוב בשני הכיוונים בלי שינוי בהגדרות', ( From 1f3278e830f739daace53364adf838e1ac66b984 Mon Sep 17 00:00:00 2001 From: palmoni5 Date: Fri, 13 Nov 2026 01:35:12 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=D7=97=D7=99=D7=A4=D7=95=D7=A9:=20=D7=91?= =?UTF-8?q?=D7=93=D7=99=D7=A7=D7=AA=20=D7=AA=D7=92=D7=99=D7=95=D7=AA=20?= =?UTF-8?q?=D7=94=D7=94=D7=A2=D7=A8=D7=94=20=D7=9E=D7=95=D7=9C=20=D7=94?= =?UTF-8?q?=D7=9E=D7=A0=D7=95=D7=A2=20=D7=94=D7=9E=D7=90=D7=95=D7=97=D7=93?= =?UTF-8?q?=20=D7=AA=D7=9E=D7=99=D7=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit המנוע המאוחד מסמן גוף הערה וסמן הערה בתוצאות של אינדקס חדש (סכמה 11), ולכן הבדיקה מול המנוע מצפה לתגיות otzaria-note ו-otzaria-note-marker תמיד, בלי משתנה הסביבה OTZARIA_EXPECT_NOTE_ANNOTATIONS. תצוגת HTML ישן בלי תגיות הערה ממשיכה להיבדק ב-snippet_note_annotations_test. --- .../snippet_note_annotations_engine_test.dart | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/test/search/snippet_note_annotations_engine_test.dart b/test/search/snippet_note_annotations_engine_test.dart index f30427fa6d..fddc7a910e 100644 --- a/test/search/snippet_note_annotations_engine_test.dart +++ b/test/search/snippet_note_annotations_engine_test.dart @@ -12,8 +12,6 @@ import '../support/search_engine_test_init.dart'; Future main() async { final ready = await tryInitSearchEngine(); - final mode = Platform.environment['OTZARIA_EXPECT_NOTE_ANNOTATIONS'] ?? '0'; - final expectAnnotations = mode == '1'; const topic = '/books/note-annotation-3292'; const path = '/notes-3292-fixture.txt'; // קטע סינתטי; ספר זה אינו מתחזה לפסקה המקורית שבמסד הספרים. @@ -25,7 +23,6 @@ Future main() async { late SearchRepository repository; setUpAll(() async { - expect(mode, isIn(['0', '1'])); if (!ready) return; directory = await Directory.systemTemp.createTemp('snippet-note-3292-'); engine = await SearchEngine.newInstance(path: directory.path); @@ -70,11 +67,8 @@ Future main() async { final result = results.single; expect(result.filePath, path); expect(result.textStatus, TextStatus.ok); - expect(result.text.contains(''), expectAnnotations); - expect( - result.text.contains(''), - expectAnnotations, - ); + expect(result.text, contains('')); + expect(result.text, contains('')); expect( SnippetBuilder.htmlToPlainText(result.text), 'גוף 12 מפורשת סוף', @@ -89,7 +83,7 @@ Future main() async { ).cast(); expect( spans.map((span) => span.text).join(), - expectAnnotations ? 'גוף 12 [הערה: מפורשת] סוף' : 'גוף 12 מפורשת סוף', + 'גוף 12 [הערה: מפורשת] סוף', ); final matched = spans .where((span) => span.style?.fontWeight == FontWeight.bold) @@ -97,14 +91,12 @@ Future main() async { expect(matched.map((span) => span.text).join(), query); expect( matched.every((span) => span.style?.fontStyle == FontStyle.italic), - expectAnnotations && query == 'מפורשת', + query == 'מפורשת', + ); + expect( + spans.singleWhere((span) => span.text == '12').style!.fontSize, + 15, ); - if (expectAnnotations) { - expect( - spans.singleWhere((span) => span.text == '12').style!.fontSize, - 15, - ); - } }, skip: ready ? false : searchEngineSkipReason); } }