Skip to content

Commit

Permalink
Limit search results to 10
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 15, 2024
1 parent 0780e9b commit df69b8f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/lib/handlers/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ abstract class PastingHandler<T> extends Handler<T> {
bloc.bake();
_firstPos = null;
_secondPos = null;
context
.getCurrentIndexCubit()
.resetTemporaryHandler(context.getDocumentBloc());
context.refresh();
}

Expand Down
12 changes: 7 additions & 5 deletions app/lib/widgets/search.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'dart:isolate';

import 'package:butterfly/bloc/document_bloc.dart';
import 'package:butterfly/helpers/point.dart';
import 'package:butterfly/visualizer/element.dart';
import 'package:butterfly/visualizer/tool.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -17,9 +16,12 @@ class SearchIntent extends Intent {

Future<List<SearchResult>> _searchIsolate(NoteData noteData, String currentPage,
DocumentPage page, String query) =>
Isolate.run(() => noteData
.search(RegExp(query, caseSensitive: false), currentPage, page)
.toList());
compute(
(e) => e.$1
.search(RegExp(e.$2, caseSensitive: false), e.$3, e.$4)
.take(10)
.toList(),
(noteData, query, currentPage, page));

class SearchButton extends StatelessWidget {
final SearchController controller;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/docs/v2/shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Some of them are written below the buttons.
* `Ctrl` + `P`: Print file
* `Ctrl` + `Shift` + `E`: Export file as image
* `Ctrl` + `Alt` + `E`: Export file as svg
* `Ctrl` + `Alt` + `Shift` + `E`: Export file as svg
* `Ctrl` + `Alt` + `Shift` + `E`: Export file as pdf
* `Ctrl` + `Alt` + `P`: Open packs
* `Ctrl` + `Alt` + `S`: Open settings

Expand Down
3 changes: 3 additions & 0 deletions metadata/en-US/changelogs/124.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Add additional selection ui options to the pen element
* Add tooltip to preset icons in export dialog
* Change general icon on background to grid
* Limit search results to 10
* Fix export on web
* Fix shape detection always enabled in pen tool
* Fix ruler not working correctly in pen tool
Expand All @@ -32,6 +33,8 @@
* FIx color fields preview shows alpha value
* Fix min slider value of stroke width
* Fix selection not working correctly when editing multiple elements
* Fix search on web
* Fix temporary stamp
* Show git hash instead of version in web version
* Upgrade to flutter 3.27

Expand Down

0 comments on commit df69b8f

Please sign in to comment.