Migrate snippets support to community snippets, support multiple snippets#2804
Merged
Conversation
Comment on lines
+193
to
+196
| const metaSnippetText = serializeSnippetFile(snippetFile) | ||
| // Escape dollar signs in the snippet text so that they don't get used as | ||
| // placeholders in the meta snippet | ||
| .replace(/\$/g, "\\$") |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we need to ensure that backslashes are properly escaped in the metaSnippetText string. This can be done by adding an additional replacement step to escape backslashes before escaping dollar signs and replacing the placeholder.
- Add a replacement step to escape backslashes using a regular expression with the
gflag. - Ensure that the order of replacements is correct: first escape backslashes, then escape dollar signs, and finally replace the placeholder.
Suggested changeset
1
packages/cursorless-engine/src/actions/GenerateSnippet/GenerateSnippet.ts
| @@ -193,2 +193,4 @@ | ||
| const metaSnippetText = serializeSnippetFile(snippetFile) | ||
| // Escape backslashes in the snippet text | ||
| .replace(/\\/g, "\\\\") | ||
| // Escape dollar signs in the snippet text so that they don't get used as |
Copilot is powered by AI and may make mistakes. Always verify output.
AndreasArvidsson
commented
Feb 1, 2025
AndreasArvidsson
commented
Feb 1, 2025
11 tasks
phillco
reviewed
Feb 4, 2025
phillco
reviewed
Feb 4, 2025
phillco
reviewed
Feb 4, 2025
phillco
reviewed
Feb 4, 2025
phillco
reviewed
Feb 4, 2025
phillco
approved these changes
Feb 4, 2025
cursorless-bot
pushed a commit
that referenced
this pull request
Feb 4, 2025
…pets (#2804) #2353 The Cursorless side of talonhub/community#1718 Will allow Cursorless to fetch multiple snippets from community and decide which one to use. ## Release notes Cursorless can now get multiple snippets from community. One for each language. Cursorless can then pick the correct snippet for the document language regardless of which document is focused at the moment. --------- Co-authored-by: Phillip Cohen <phillip@phillip.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2353
The Cursorless side of talonhub/community#1718
Will allow Cursorless to fetch multiple snippets from community and decide which one to use.
Release notes
Cursorless can now get multiple snippets from community. One for each language. Cursorless can then pick the correct snippet for the document language regardless of which document is focused at the moment.