Elffuss BraidHub

kikocis/continue public

Update findSearchMatch.ts
Changeset62c4c3e6fad7c0bd0a569ab2a63c0c793174d6831bbcd50f2c5e1d9a448b159f
AuthorPatrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-06-27 08:16 -07:00
CommitterPatrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-06-27 08:16 -07:00
Parentsbdaaa3ef81c4

Browse the files at this changeset

1 file changed

modified core/edit/searchAndReplace/findSearchMatch.ts +12 −12
@@ -11,45 +11,45 @@
1111 /**
1212 * Find the exact match position for search content in file content.
1313 * Uses simple exact matching with trimmed newlines for MVP.
14- *
14+ *
1515 * Matching Strategy:
1616 * 1. If search content is empty, matches at the beginning of file (position 0)
1717 * 2. Try exact string match first
1818 * 3. Fallback to trimmed content match if exact match fails
19- *
19+ *
2020 * @param fileContent - The complete content of the file to search in
2121 * @param searchContent - The content to search for
2222 * @returns Match result with character positions, or null if no match found
2323 */
2424 export function findSearchMatch(
25- fileContent: string,
26- searchContent: string
25+ fileContent: string,
26+ searchContent: string,
2727 ): SearchMatchResult | null {
2828 // Strip leading/trailing newlines for basic matching strategy
2929 const trimmedSearchContent = searchContent.trim();
30-
31- if (trimmedSearchContent === '') {
30+
31+ if (trimmedSearchContent === "") {
3232 // Empty search content matches the beginning of the file
3333 return { startIndex: 0, endIndex: 0 };
3434 }
35-
35+
3636 // Try exact match first
3737 const exactIndex = fileContent.indexOf(searchContent);
3838 if (exactIndex !== -1) {
3939 return {
4040 startIndex: exactIndex,
41- endIndex: exactIndex + searchContent.length
41+ endIndex: exactIndex + searchContent.length,
4242 };
4343 }
44-
44+
4545 // Fallback: try trimmed content match
4646 const trimmedIndex = fileContent.indexOf(trimmedSearchContent);
4747 if (trimmedIndex !== -1) {
4848 return {
4949 startIndex: trimmedIndex,
50- endIndex: trimmedIndex + trimmedSearchContent.length
50+ endIndex: trimmedIndex + trimmedSearchContent.length,
5151 };
5252 }
53-
53+
5454 return null;
55-}
No newline at the end of the file
55+}