mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 11:27:32 +00:00
adjustment: simplified caret helper
This commit is contained in:
@@ -98,18 +98,14 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
|
|||||||
const [lastCaretPos, setLastCaretPos] = useState<number>(0);
|
const [lastCaretPos, setLastCaretPos] = useState<number>(0);
|
||||||
|
|
||||||
const isCaretInsideReference = (str: string, start: number) => {
|
const isCaretInsideReference = (str: string, start: number) => {
|
||||||
const matches = [...str.matchAll(REGEX_SECRET_REFERENCE_FIND)];
|
const match = [...str.matchAll(REGEX_SECRET_REFERENCE_FIND)].find(
|
||||||
for (let i = 0; i < matches.length; i += 1) {
|
(entry) =>
|
||||||
const match = matches[i];
|
typeof entry?.index !== "undefined" &&
|
||||||
if (
|
entry.index <= start &&
|
||||||
typeof match?.index !== "undefined" &&
|
start < entry.index + entry[0].length
|
||||||
match.index <= start &&
|
);
|
||||||
start < match.index + match[0].length
|
|
||||||
) {
|
return match || null;
|
||||||
return match;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const setCaretPos = (caretPos: number) => {
|
const setCaretPos = (caretPos: number) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user