aws / language-servers

AWS related Language Servers
Apache License 2.0
17 stars 15 forks source link

Escape backticks in user prompts #279

Closed ege0zcan closed 1 month ago

ege0zcan commented 1 month ago

Problem

Right now the way we create markdown code blocks for send to prompt is a bit too naive and is prone to breaking when a user selection contains backticks. See for example:

image

Solution

To overcome this, we can implement a function that finds the longest backtick sequence inside a provided user selection and then creates the markdown code block with more backticks than that amount

This has the small caveat that codeblocks with backticks will now consume more of the character limit

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

ege0zcan commented 1 month ago

Had an offline discussion with @dogusata about this. Although this solution works, it introduces some additional computation that needs to be done by the regex and then the sorting. We decided to update the logic in mynah-ui to let mynah handle codeblocks by using the ~~~ syntax for codeblocks

https://github.com/aws/mynah-ui/pull/51