Skip to content

Commit

Permalink
Merge pull request #200 from aws/frapicc/fix-code-trimming-ides
Browse files Browse the repository at this point in the history
Fix code marks trimming for different ides
  • Loading branch information
Jurredr authored Dec 10, 2024
2 parents 69cdd2e + e5a112f commit 93aca00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/components/chat-item/chat-prompt-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,21 @@ export class ChatPromptInput {
});
codeAttachment = this.userPromptHistory[this.userPromptHistoryIndex].codeAttachment ?? '';
}
if (codeAttachment.trim().length > 0) {
codeAttachment = codeAttachment
.replace(/~~~~~~~~~~/, '')
.replace(/~~~~~~~~~~$/, '')
.trim();
codeAttachment = codeAttachment.trim();
if (codeAttachment.length > 0) {
// the way we mark code in our example mynah client
if (codeAttachment.startsWith('~~~~~~~~~~') && codeAttachment.endsWith('~~~~~~~~~~')) {
codeAttachment = codeAttachment
.replace(/^~~~~~~~~~~/, '')
.replace(/~~~~~~~~~~$/, '')
.trim();
} else if (codeAttachment.startsWith('```') && codeAttachment.endsWith('```')) {
// the way code is marked in VScode and JetBrains extensions
codeAttachment = codeAttachment
.replace(/^```/, '')
.replace(/```$/, '')
.trim();
}
this.addAttachment(codeAttachment, 'code');
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui-tests/__test__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('Open MynahUI', () => {
it('should navigate down to next prompt', async () => {
await navigatePromptsDown(page);
},
20000);
25000);
it('should navigate down to current empty prompt', async () => {
await navigatePromptsToEmpty(page);
});
Expand Down

0 comments on commit 93aca00

Please sign in to comment.