From 80d4e2bd6530b79af3977accbc65612875b24c2b Mon Sep 17 00:00:00 2001 From: A1phaCat Date: Sun, 15 Nov 2026 18:48:15 +1100 Subject: [PATCH 1/2] feat: add search in files history --- src/sidebarApps/searchInFiles/index.js | 121 +++++++++++++++++++++- src/sidebarApps/searchInFiles/styles.scss | 15 +++ tests/unit/searchInFilesHistory.test.js | 101 ++++++++++++++++++ tests/unit/searchReplaceAll.test.js | 1 + 4 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 tests/unit/searchInFilesHistory.test.js diff --git a/src/sidebarApps/searchInFiles/index.js b/src/sidebarApps/searchInFiles/index.js index 35ef095b0..69614a4f1 100644 --- a/src/sidebarApps/searchInFiles/index.js +++ b/src/sidebarApps/searchInFiles/index.js @@ -4,6 +4,7 @@ import autosize from "autosize"; import { getDocText } from "cm/editorUtils"; import Checkbox from "components/checkbox"; import Sidebar, { preventSlide } from "components/sidebar"; +import select from "dialogs/select"; import escapeStringRegexp from "escape-string-regexp"; import Reactive from "html-tag-js/reactive"; import Ref from "html-tag-js/ref"; @@ -11,6 +12,7 @@ import fileIndex from "lib/fileIndex"; import files, { Tree, whenReady as waitForFileList } from "lib/fileList"; import openFile from "lib/openFile"; import { addedFolder } from "lib/openFolder"; +import searchHistory from "lib/searchHistory"; import settings from "lib/settings"; import helpers from "utils/helpers"; import { createSearchResultView } from "./cmResultView"; @@ -35,6 +37,8 @@ const $include = Ref(); const $wholeWord = Ref(); const $caseSensitive = Ref(); const $useIndex = Ref(); +const $btnSearchHistory = Ref(); +const $btnReplaceHistory = Ref(); const $btnReplaceAll = Ref(); const $resultOverview = Ref(); const $resultHeader = Ref(); @@ -136,6 +140,12 @@ addEventListener($useIndex, "change", onInput); addEventListener($search, "input", onInput); addEventListener($include, "input", onInput); addEventListener($exclude, "input", onInput); +addEventListener($btnSearchHistory, "click", () => + openPatternHistory($search, strings["search"]), +); +addEventListener($btnReplaceHistory, "click", () => + openPatternHistory($replace, strings["replace"]), +); addEventListener($btnReplaceAll, "click", replaceAll); files.on("push-file", () => { @@ -257,7 +267,15 @@ export default [ type="search" name="search" placeholder={strings["search"]} + onchange={rememberSearchPattern} + onkeydown={onSearchHistoryKeydown} /> +
@@ -266,7 +284,15 @@ export default [ type="search" name="replace" placeholder={strings["replace"]} + onchange={rememberReplacePattern} + onkeydown={onReplaceHistoryKeydown} /> +