Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5a1a26b
fix: profile button text not centralized
devvaannsh Jul 9, 2025
4252e76
feat: add cancel button in add snippet panel
devvaannsh Jul 9, 2025
ae7dbc4
fix: save button always remain disabled
devvaannsh Jul 9, 2025
4004cfd
feat: auto update API docs
devvaannsh Jul 10, 2025
e5d2653
fix: increase panel min size so that the save, cancel buttons are alw…
devvaannsh Jul 10, 2025
078502c
fix: update text in the no snippets present panel
devvaannsh Jul 10, 2025
f4db68f
fix: back button text not properly centralized
devvaannsh Jul 10, 2025
4236acd
feat: add check state on menu item when panel is open
devvaannsh Jul 10, 2025
f985b8b
fix: alignment of plus icon in the add snippet button
devvaannsh Jul 10, 2025
c619e32
fix: back button alignment
devvaannsh Jul 10, 2025
1ff336d
fix: move the content a bit right to maintain hierarchy structure
devvaannsh Jul 10, 2025
e7d59a3
fix: made close button styling consistent to other panels close button
devvaannsh Jul 10, 2025
a5932f5
fix: make filter input consistent to other panels filter input
devvaannsh Jul 10, 2025
5ad4a12
fix: set min width to the template textare to keep it consistent to o…
devvaannsh Jul 10, 2025
41bc07d
feat: disable reset button in edit panel when nothing to reset
devvaannsh Jul 10, 2025
11552b6
fix: ui layout issues in snippets list header
devvaannsh Jul 12, 2025
90a8a51
fix: font weight issue for snippet list
devvaannsh Jul 12, 2025
99c819a
feat: allow users to write file extension in any format
devvaannsh Jul 12, 2025
f941f01
fix: mutliple commas appearing when parsing failed
devvaannsh Jul 12, 2025
4148d56
fix: remove trailing dot from result
devvaannsh Jul 12, 2025
3191f02
feat: save snippets to file storage instead of prefs manager
devvaannsh Jul 12, 2025
2a12fd3
feat: replace reset button with cancel button in the edit snippets panel
devvaannsh Jul 12, 2025
ae58526
fix: prevent processing file extension where two dots are there to su…
devvaannsh Jul 12, 2025
589b6d1
refactor: replace template with Click to edit template and so on
devvaannsh Jul 12, 2025
8068629
refactor: store snippets directly in file instead of preferencesBase
devvaannsh Jul 13, 2025
206daed
fix: snippets 3 dots in the menu item was not consistent with the 3 d…
devvaannsh Jul 13, 2025
77a2391
fix: remove redundant then blocks
devvaannsh Jul 14, 2025
8c502ab
fix: remove unnecessary pretty printing when saving file
devvaannsh Jul 14, 2025
2947c2d
fix: directly return jsPromise for writeText instead of creating a ne…
devvaannsh Jul 14, 2025
d4491e1
feat: report unexpected errors to bugsnag
devvaannsh Jul 14, 2025
63d1a7b
feat: move all strings to strings.js file
devvaannsh Jul 14, 2025
81da0d5
fix: strings in html not appearing
devvaannsh Jul 14, 2025
1350ded
feat: add metrics to track snippets usage
devvaannsh Jul 14, 2025
10ecd71
fix: remove redundant console error as logger is already present
devvaannsh Jul 14, 2025
f280ab1
fix: replace reject with resolve as reject might break boot
devvaannsh Jul 14, 2025
3dc6e1d
fix: instead of hard-coding file names use language manager
devvaannsh Jul 14, 2025
76d6aae
fix: use stringUtils to replace strings
devvaannsh Jul 14, 2025
818ef69
fix: change cursor to pointer when close button for snippets panel is…
devvaannsh Jul 14, 2025
9c0b25a
fix: return a "file" type if the snippet is enabled only for specific…
devvaannsh Jul 15, 2025
be92f9a
fix: optimize the snippet code hints to prevent checking for hints on…
devvaannsh Jul 15, 2025
d518c53
fix: improve readability of isSnippetSupportedInLanguageContext function
devvaannsh Jul 15, 2025
862131d
fix: remove redundant try catch block from getCurrentLanguageContext …
devvaannsh Jul 15, 2025
d27e2b2
refactor: replace ?. with x && y
devvaannsh Jul 15, 2025
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
20 changes: 20 additions & 0 deletions docs/API-Reference/editor/CodeHintManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ insertHintOnTab Preference.
* [.registerHintProvider(provider, languageIds, priority)](#module_CodeHintManager..registerHintProvider)
* [.hasValidExclusion(exclusion, textAfterCursor)](#module_CodeHintManager..hasValidExclusion) ⇒ <code>boolean</code>
* [.isOpen()](#module_CodeHintManager..isOpen) ⇒ <code>boolean</code>
* [.showHintsAtTop(handler)](#module_CodeHintManager..showHintsAtTop)
* [.clearHintsAtTop()](#module_CodeHintManager..clearHintsAtTop)

<a name="module_CodeHintManager..registerHintProvider"></a>

Expand Down Expand Up @@ -263,3 +265,21 @@ Test if a hint popup is open.

**Kind**: inner method of [<code>CodeHintManager</code>](#module_CodeHintManager)
**Returns**: <code>boolean</code> - - true if the hints are open, false otherwise.
<a name="module_CodeHintManager..showHintsAtTop"></a>

### CodeHintManager.showHintsAtTop(handler)
Register a handler to show hints at the top of the hint list.
This API allows extensions to add their own hints at the top of the standard hint list.

**Kind**: inner method of [<code>CodeHintManager</code>](#module_CodeHintManager)

| Param | Type | Description |
| --- | --- | --- |
| handler | <code>Object</code> | A hint provider object with standard methods: - hasHints: function(editor, implicitChar) - returns true if hints are available - getHints: function(editor, implicitChar) - returns hint response object with hints array - insertHint: function(hint) - handles hint insertion, returns true if handled |

<a name="module_CodeHintManager..clearHintsAtTop"></a>

### CodeHintManager.clearHintsAtTop()
Unregister the hints at top handler.

**Kind**: inner method of [<code>CodeHintManager</code>](#module_CodeHintManager)
4 changes: 3 additions & 1 deletion src/extensionsIntegrated/CustomSnippets/UIHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

/* eslint-disable no-invalid-this */
define(function (require, exports, module) {
const StringUtils = require("utils/StringUtils");
const Global = require("./global");
const Strings = require("strings");

/**
* this is a generic function to show error messages for input fields
Expand Down Expand Up @@ -187,7 +189,7 @@ define(function (require, exports, module) {
const wrapperId = isEditForm ? "edit-abbr-box-wrapper" : "abbr-box-wrapper";
const errorId = isEditForm ? "edit-abbreviation-duplicate-error" : "abbreviation-duplicate-error";

showError(inputId, wrapperId, `A snippet with abbreviation "${abbreviation}" already exists.`, errorId);
showError(inputId, wrapperId, StringUtils.format(Strings.CUSTOM_SNIPPETS_DUPLICATE_ERROR, abbreviation), errorId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
define(function (require, exports, module) {
const CodeHintManager = require("editor/CodeHintManager");
const EditorManager = require("editor/EditorManager");
const Metrics = require("utils/Metrics");

const Global = require("./global");
const Driver = require("./driver");
Expand Down Expand Up @@ -118,6 +119,10 @@ define(function (require, exports, module) {
const editor = EditorManager.getFocusedEditor();

if (editor) {
// to track the usage metrics
const fileCategory = Helper.categorizeFileExtensionForMetrics(matchedSnippet.fileExtension);
Metrics.countEvent(Metrics.EVENT_TYPE.EDITOR, "snipt", `use.${fileCategory}`);

// replace the typed abbreviation with the template text using cursor manager
const wordInfo = Driver.getWordBeforeCursor();
const start = { line: wordInfo.line, ch: wordInfo.ch + 1 };
Expand Down
43 changes: 32 additions & 11 deletions src/extensionsIntegrated/CustomSnippets/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
*
*/

/* global logger */
define(function (require, exports, module) {
const EditorManager = require("editor/EditorManager");
const Metrics = require("utils/Metrics");

const Global = require("./global");
const Helper = require("./helper");
Expand All @@ -43,9 +45,19 @@ define(function (require, exports, module) {

if (shouldAddSnippetToList(snippetData)) {
Global.SnippetHintsList.push(snippetData);
Helper.rebuildOptimizedStructures();
Helper.clearAllInputFields();
Helper.toggleSaveButtonDisability();
SnippetsState.saveSnippetsToState();

// snippet creating metrics
const fileCategory = Helper.categorizeFileExtensionForMetrics(snippetData.fileExtension);
Metrics.countEvent(Metrics.EVENT_TYPE.EDITOR, "snipt", `add.${fileCategory}`);

// save to file storage
SnippetsState.saveSnippetsToState()
.catch(function (error) {
logger.reportError(error, "Custom Snippets: failed to save new snippet to file storage");
});

// we need to move back to snippets list view after a snippet is saved
UIHelper.showSnippetListMenu();
Expand Down Expand Up @@ -87,7 +99,13 @@ define(function (require, exports, module) {
// update the snippet in the list
if (snippetIndex !== -1) {
Global.SnippetHintsList[snippetIndex] = editedData;
SnippetsState.saveSnippetsToState();
Helper.rebuildOptimizedStructures();

// save to file storage
SnippetsState.saveSnippetsToState()
.catch(function (error) {
logger.reportError(error, "Custom Snippets: failed to save edited snippet to file storage");
});

// clear the stored data
$editView.removeData("originalSnippet");
Expand All @@ -100,19 +118,24 @@ define(function (require, exports, module) {
}

/**
* This function handles the reset button click for editing a snippet
* It restores the original snippet data in the edit form
* This function is responsible to handle the cancel button click in the edit-snippet panel
* this resets the format to the last saved values and then moves back to the snippets-list panel
*/
function handleResetBtnClick() {
function handleCancelEditBtnClick() {
const $editView = $("#custom-snippets-edit");
const originalSnippet = $editView.data("originalSnippet");

if (originalSnippet) {
// restore original data in the form
// restore original data in the form to reset any changes
Helper.populateEditForm(originalSnippet);
// update save button state
Helper.toggleEditSaveButtonDisability();
}

$editView.removeData("originalSnippet");
$editView.removeData("snippetIndex");

// navigate back to snippets list
UIHelper.showSnippetListMenu();
SnippetsList.showSnippetsList();
}

/**
Expand Down Expand Up @@ -164,10 +187,8 @@ define(function (require, exports, module) {
};
}



exports.getWordBeforeCursor = getWordBeforeCursor;
exports.handleSaveBtnClick = handleSaveBtnClick;
exports.handleEditSaveBtnClick = handleEditSaveBtnClick;
exports.handleResetBtnClick = handleResetBtnClick;
exports.handleCancelEditBtnClick = handleCancelEditBtnClick;
});
Loading
Loading