Skip to content

Commit

Permalink
fix(agent): fix postprocess remove duplicated block closing line. (Ta…
Browse files Browse the repository at this point in the history
  • Loading branch information
icycodes authored Jan 22, 2024
1 parent f220ba9 commit b3cbe36
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
description = 'Remove duplication: duplicated block closing line: case 01'

[config]
# use default config

[context]
filepath = 'checks.js'
language = 'javascript'
# indentation = ' ' # not specified
text = '''
function log(obj) {├
console.log(obj);
};┤
}
'''

[expected]
text = '''
function log(obj) {├
console.log(obj);┤
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export function removeDuplicatedBlockClosingLine(): PostprocessFilter {
}
const suffixBeginningLine = suffixLines[suffixBeginningIndex]!;

if (inputEndingLine.startsWith(suffixBeginningLine) || suffixBeginningLine.startsWith(inputEndingLine)) {
if (
inputEndingLine.startsWith(suffixBeginningLine.trimEnd()) ||
suffixBeginningLine.startsWith(inputEndingLine.trimEnd())
) {
logger.debug({ inputLines, suffixLines }, "Removing duplicated block closing line");
return inputLines
.slice(0, inputLines.length - 1)
Expand Down

0 comments on commit b3cbe36

Please sign in to comment.