MCPcopy
hub / github.com/codeaashu/claude-code / findActualString

Function findActualString

src/tools/FileEditTool/utils.ts:73–93  ·  view source on GitHub ↗
(
  fileContent: string,
  searchString: string,
)

Source from the content-addressed store, hash-verified

71 * @returns The actual string found in the file, or null if not found
72 */
73export function findActualString(
74 fileContent: string,
75 searchString: string,
76): string | null {
77 // First try exact match
78 if (fileContent.includes(searchString)) {
79 return searchString
80 }
81
82 // Try with normalized quotes
83 const normalizedSearch = normalizeQuotes(searchString)
84 const normalizedFile = normalizeQuotes(fileContent)
85
86 const searchIndex = normalizedFile.indexOf(normalizedSearch)
87 if (searchIndex !== -1) {
88 // Find the actual string in the file that matches
89 return fileContent.substring(searchIndex, searchIndex + searchString.length)
90 }
91
92 return null
93}
94
95/**
96 * When old_string matched via quote normalization (curly quotes in file,

Callers 4

validateInputFunction · 0.85
callFunction · 0.85
loadRejectionDiffFunction · 0.85
normalizeEditFunction · 0.85

Calls 1

normalizeQuotesFunction · 0.85

Tested by

no test coverage detected