Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
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
17 changes: 12 additions & 5 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,11 @@ define(function (require, exports, module) {
* @param {{line:number, ch:number}=} end If not specified, defaults to start.
* @param {boolean} center true to center the viewport
* @param {number} centerOptions Option value, or 0 for no options; one of the BOUNDARY_* constants above.
* @param {?string} origin An optional string that describes what other selection or edit operations this
* should be merged with for the purposes of undo. See Document.replaceRange() for more details.
*/
Editor.prototype.setSelection = function (start, end, center, centerOptions) {
this.setSelections([{start: start, end: end || start}], center, centerOptions);
Editor.prototype.setSelection = function (start, end, center, centerOptions, origin) {
this.setSelections([{start: start, end: end || start}], center, centerOptions, origin);
};

/**
Expand All @@ -1158,15 +1160,20 @@ define(function (require, exports, module) {
* one selection has primary set to true. If none has primary set to true, the last one is primary.
* @param {boolean} center true to center the viewport around the primary selection.
* @param {number} centerOptions Option value, or 0 for no options; one of the BOUNDARY_* constants above.
* @param {?string} origin An optional string that describes what other selection or edit operations this
* should be merged with for the purposes of undo. See Document.replaceRange() for more details.
*/
Editor.prototype.setSelections = function (selections, center, centerOptions) {
var primIndex = selections.length - 1;
Editor.prototype.setSelections = function (selections, center, centerOptions, origin) {
var primIndex = selections.length - 1, options;
if (origin) {
options = { origin: origin };
}
this._codeMirror.setSelections(_.map(selections, function (sel, index) {
if (sel.primary) {
primIndex = index;
}
return { anchor: sel.reversed ? sel.end : sel.start, head: sel.reversed ? sel.start : sel.end };
}), primIndex);
}), primIndex, options);
if (center) {
this.centerOnCursor(centerOptions);
}
Expand Down