Skip to content

Commit

Permalink
fix: replaceRange could now be implemented as an instance of the Rang…
Browse files Browse the repository at this point in the history
…e interface, rather than being an instance of the Range class
  • Loading branch information
mkslanc committed Apr 26, 2023
1 parent 990745a commit e1bdccc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ var SnippetManager = function() {
var processedSnippet = processSnippetText.call(this, editor, snippetText);

var range = editor.getSelectionRange();
if (replaceRange && replaceRange.compareRange(range) === 0) {
if (replaceRange && range.compareRange(replaceRange) === 0) {
range = replaceRange;
}
var end = editor.session.replace(range, processedSnippet.text);
Expand Down
8 changes: 8 additions & 0 deletions src/snippets_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ module.exports = {
this.editor.tabstopManager.tabNext();
editor.execCommand("insertstring", ".");
assert.equal(editor.getValue(), "qt qt qt.");
},
"test: should work as expected with object of Range interface": function () {
var content = "test";
this.editor.setValue("replace1");
snippetManager.insertSnippet(this.editor, content, {
start: {row: 0, column: 0}, end: {row: 0, column: 7}
});
assert.equal(this.editor.getValue(), "test1");
}
};

Expand Down

0 comments on commit e1bdccc

Please sign in to comment.