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

Function preserveQuoteStyle

src/tools/FileEditTool/utils.ts:104–136  ·  view source on GitHub ↗
(
  oldString: string,
  actualOldString: string,
  newString: string,
)

Source from the content-addressed store, hash-verified

102 * otherwise it's a closing quote.
103 */
104export function preserveQuoteStyle(
105 oldString: string,
106 actualOldString: string,
107 newString: string,
108): string {
109 // If they're the same, no normalization happened
110 if (oldString === actualOldString) {
111 return newString
112 }
113
114 // Detect which curly quote types were in the file
115 const hasDoubleQuotes =
116 actualOldString.includes(LEFT_DOUBLE_CURLY_QUOTE) ||
117 actualOldString.includes(RIGHT_DOUBLE_CURLY_QUOTE)
118 const hasSingleQuotes =
119 actualOldString.includes(LEFT_SINGLE_CURLY_QUOTE) ||
120 actualOldString.includes(RIGHT_SINGLE_CURLY_QUOTE)
121
122 if (!hasDoubleQuotes && !hasSingleQuotes) {
123 return newString
124 }
125
126 let result = newString
127
128 if (hasDoubleQuotes) {
129 result = applyCurlyDoubleQuotes(result)
130 }
131 if (hasSingleQuotes) {
132 result = applyCurlySingleQuotes(result)
133 }
134
135 return result
136}
137
138function isOpeningContext(chars: string[], index: number): boolean {
139 if (index === 0) {

Callers 3

callFunction · 0.85
loadRejectionDiffFunction · 0.85
normalizeEditFunction · 0.85

Calls 2

applyCurlyDoubleQuotesFunction · 0.85
applyCurlySingleQuotesFunction · 0.85

Tested by

no test coverage detected