Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Add whole word matching functionality to FindReplace component (#290)

Myles Scolnick3d26426917d8
diff --git a/frontend/src/components/find-replace/find-replace.tsx b/frontend/src/components/find-replace/find-replace.tsx
index 091b5258a1..5ee5233e32 100644
--- a/frontend/src/components/find-replace/find-replace.tsx
+++ b/frontend/src/components/find-replace/find-replace.tsx
@@ -21,6 +21,7 @@ import {
ArrowRightIcon,
CaseSensitiveIcon,
RegexIcon,
+ WholeWordIcon,
XIcon,
} from "lucide-react";
import { useHotkey } from "@/hooks/useHotkey";
@@ -58,7 +59,14 @@ export const FindReplace: React.FC = () => {
const matches = getMatches();
// False count means an invalid regex
setMatches(matches === false ? undefined : matches);
- }, [state.findText, state.isOpen]);
+ }, [
+ // Re-search when any of these change
+ state.findText,
+ state.isOpen,
+ state.caseSensitive,
+ state.regexp,
+ state.wholeWord,
+ ]);
if (!state.isOpen) {
return null;
@@ -142,6 +150,18 @@ export const FindReplace: React.FC = () => {
<CaseSensitiveIcon className="w-4 h-4" />
</Toggle>
</Tooltip>
+ <Tooltip content="Match Whole Word">
+ <Toggle
+ size="sm"
+ pressed={state.wholeWord}
+ data-state={state.wholeWord ? "on" : "off"}
+ onPressedChange={(pressed) =>
+ dispatch({ type: "setWholeWord", wholeWord: pressed })
+ }
+ >
+ <WholeWordIcon className="w-4 h-4" />
+ </Toggle>
+ </Tooltip>
<Tooltip content="Use Regular Expression">
<Toggle
size="sm"