feat: show current/total search results

This commit is contained in:
thecodrr
2022-07-25 15:23:27 +05:00
parent 9a1a423e59
commit f603f54a08

View File

@@ -8,7 +8,7 @@ import { Editor } from "../../types";
export type SearchReplacePopupProps = { editor: Editor }; export type SearchReplacePopupProps = { editor: Editor };
export function SearchReplacePopup(props: SearchReplacePopupProps) { export function SearchReplacePopup(props: SearchReplacePopupProps) {
const { editor } = props; const { editor } = props;
const { selectedText, results } = editor.storage const { selectedText, results, selectedIndex } = editor.storage
.searchreplace as SearchStorage; .searchreplace as SearchStorage;
const [isReplacing, setIsReplacing] = useState(false); const [isReplacing, setIsReplacing] = useState(false);
@@ -160,8 +160,7 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
px: 1, px: 1,
}} }}
> >
{results ? `${results.length}` : "0"} {results ? `${selectedIndex + 1}/${results.length}` : ""}
{isExpanded ? "" : " results"}
</Text> </Text>
</Flex> </Flex>
</Flex> </Flex>