Skip to content

Custom Snippets Feature #2278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open

Custom Snippets Feature #2278

wants to merge 61 commits into from

Conversation

devvaannsh
Copy link
Member

@devvaannsh devvaannsh commented May 29, 2025

Tracking issue: #2268
This PR brings the support of Custom Snippets feature to Phoenix.

Custom snippets let users define short abbreviations. When typed in the editor, these trigger a hint. Selecting the hint expands it into the corresponding template text.

This helps reduce development time by avoiding repetitive typing.

Visual References
https://github.com/user-attachments/assets/a0a8d4f4-42d1-4c94-b2e2-4529371284c3 <- checkout this video too.

Untitled.video.-.Made.with.Clipchamp.20.mp4

devvaannsh added 30 commits June 1, 2025 13:51
@devvaannsh
Copy link
Member Author

This are some more changes that are made (after rebase):
(Each point refers to a commit)

  1. Move all the files to parent 'Custom Snippets' directory and removed the 'src' directory.

  2. Added license to all the files of custom snippets

  3. There was a bug where custom snippets in code completion were showing up in creation order instead of relevance order. So if a user had snippets "clgi" and "clg", and "clgi" was created first, typing "clg" would show "clgi" at the top even though "clg" is an exact match. Fixed that by prioritizing exact matches over partial matches. Now when users type "clg", they'll see "clg" first (exact match) followed by "clgi" (partial match).

  4. Snippet description was not properly visible. Also increased the max-description length from 70 to 80 chars.
    Before
    custom-snippets
    After
    Screenshot 2025-06-07 024002

  5. When a multiline snippet was expanded into the editor (maybe inside a function or something) then the indentation was not being taken care of. Fixed that.

  6. Remove optional chaining as it is not supported and was causing the prod:release build to fail.

@abose abose requested a review from Copilot June 16, 2025 04:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a Custom Snippets feature to allow users to quickly expand short abbreviations into their corresponding code templates. Key changes include new CSS rules and Less imports to style custom snippet hints, new extension modules (such as snippetsState, snippetsList, snippetCodeHints, driver, and codeHintIntegration) for managing snippet state and editor integration, and a new UI panel for displaying and managing custom snippets.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/styles/brackets_patterns_override.less Adds new styles for custom snippet code hints and snippet description display
src/styles/brackets.less Imports the custom snippets stylesheet
src/extensionsIntegrated/loader.js Loads the new Custom Snippets extension
src/extensionsIntegrated/CustomSnippets/*.js Introduces several new modules to manage snippet state, list, code hints, and integration with the editor
src/extensionsIntegrated/CustomSnippets/htmlContent/snippets-panel.html Provides the new UI panel for custom snippets

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants