in packages/core/src/codewhisperer/util/closingBracketUtil.ts [160:208]
function getQuotesToRemove(
editor: vscode.TextEditor,
recommendation: string,
leftContext: string,
rightContext: string,
endPosition: vscode.Position,
startPosition: vscode.Position
) {
let leftQuote: string | undefined = undefined
let leftIndex: number | undefined = undefined
for (let i = leftContext.length - 1; i >= 0; i--) {
const char = leftContext[i]
if (quotes.includes(char)) {
leftQuote = char
leftIndex = leftContext.length - i
break
}
}
let rightQuote: string | undefined = undefined
let rightIndex: number | undefined = undefined
for (let i = 0; i < rightContext.length; i++) {
const char = rightContext[i]
if (quotes.includes(char)) {
rightQuote = char
rightIndex = i
break
}
}
let quoteCountInReco = 0
if (leftQuote && rightQuote && leftQuote === rightQuote) {
for (const char of recommendation) {
if (quotes.includes(char) && char === leftQuote) {
quoteCountInReco++
}
}
}
if (leftIndex !== undefined && rightIndex !== undefined && quoteCountInReco % 2 !== 0) {
const p = editor.document.positionAt(editor.document.offsetAt(endPosition) + rightIndex)
if (endPosition.line === startPosition.line && endPosition.line === p.line) {
return [rightIndex]
}
}
return []
}