Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateEditorSelection(source: string = SOURCE_API) {
if (this._settingBrowserSelection) return this._settingBrowserSelection = false;
const range = this.getSelection();
// Store the last non-null selection for restoration on focus()
if (range) this.lastSelection = range;
this._settingEditorSelection = true;
this.editor.setSelection(range, source);
this._settingEditorSelection = false;
// If the selection was adjusted when set then update the browser's selection
const selection = this.getBrowserSelection();
if (!shallowEqual(range, this.editor.selection) || (range && range[0] === range[1] && selection && selection.type === 'Range')) {
this.updateBrowserSelection();
}
}