Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adress review feedback
Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
  • Loading branch information
JonasHelming committed Jan 29, 2025
commit 86509198f57c8c1788a6799af094a2c5d07acc6f
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('CodeCompletionAgentImpl', () => {
});

it('should remove all text after second occurrence of backticks', () => {
const input = '```js\nlet x = 10;\n```\nTrailing text should be removed```';
const input = '```js\nlet x = 10;\n```\nTrailing text should be removed';
const output = codeCompletionProcessor.stripBackticks(input);
expect(output).to.equal('let x = 10;');
});
Expand All @@ -74,5 +74,11 @@ describe('CodeCompletionAgentImpl', () => {
expect(output).to.equal('print("Hello, World!")');
});

it('should handle multiple internal backticks correctly', () => {
const input = '```\nFoo```Bar```FooBar```';
const output = codeCompletionProcessor.stripBackticks(input);
expect(output).to.equal('Foo```Bar```FooBar');
});

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class DefaultCodeCompletionPostProcessor {
if (text.startsWith('```')) {
// Remove the first backticks and any language identifier
const startRemoved = text.slice(3).replace(/^\w*\n/, '');
const secondBacktickIndex = startRemoved.indexOf('```');
return secondBacktickIndex !== -1 ? startRemoved.slice(0, secondBacktickIndex).trim() : startRemoved.trim();
const lastBacktickIndex = startRemoved.lastIndexOf('```');
return lastBacktickIndex !== -1 ? startRemoved.slice(0, lastBacktickIndex).trim() : startRemoved.trim();
}
return text;
}
Expand Down
Loading