Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _selectCurrentDocument() {
// If fullPath corresonds to the current doc being viewed then opening the file won't
// trigger a currentDocumentChanged event, so we need to trigger a documentSelectionFocusChange
// in this case to signify the selection focus has changed even though the current document has not.
$(exports).triggerHandler("documentSelectionFocusChange");
// Ensure the editor has focus even though we didn't open a new file.
EditorManager.focusEditor();
}
// *and* if at least one other view still exists
if (!promptOnly && DocumentManager.getOpenDocumentForPath(file.fullPath)) {
doRevert(doc)
.then(result.resolve, result.reject);
} else {
result.resolve();
}
}
});
result.always(function () {
EditorManager.focusEditor();
});
} else {
// File is not open, or IS open but Document not dirty: close immediately
doClose(file);
EditorManager.focusEditor();
result.resolve();
}
return promise;
}
// Nagivate to file and line number
if (fullPath) {
CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, {fullPath: fullPath})
.done(function () {
if (!isNaN(gotoLine)) {
EditorManager.getCurrentFullEditor().setCursorPos(cursor);
}
});
} else if (!isNaN(gotoLine)) {
EditorManager.getCurrentFullEditor().setCursorPos(cursor);
}
}
this._close();
EditorManager.focusEditor();
};
.insertBefore("#editor-holder");
if (animate) {
this._$root.addClass("popout offscreen");
// Forcing the renderer to do a layout, which will cause it to apply the transform for the "offscreen"
// class, so it will animate when you remove the class.
window.getComputedStyle(this._$root.get(0)).getPropertyValue("top");
this._$root.removeClass("popout offscreen");
}
// If something *other* than an editor (like another modal bar) has focus, set the focus
// to the editor here, before opening up the new modal bar. This ensures that the old
// focused item has time to react and close before the new modal bar is opened.
// See bugs #4287 and #3424
if (!EditorManager.getFocusedEditor()) {
EditorManager.focusEditor();
}
if (autoClose) {
this._autoClose = true;
this._$root.on("keydown", this._handleKeydown);
window.document.body.addEventListener("focusin", this._handleFocusChange, true);
// Set focus to the first input field, or the first button if there is no input field.
// TODO: remove this logic?
var $firstInput = $("input[type='text']", this._$root).first();
if ($firstInput.length > 0) {
$firstInput.focus();
} else {
$("button", this._$root).first().focus();
}
}
.always(function () {
if (_restartPending) {
// Restart the sync if needed
_restartPending = false;
_alreadyChecking = false;
syncOpenDocuments();
} else {
// We're really done!
_alreadyChecking = false;
// If we showed a dialog, restore focus to editor
if (editConflicts.length > 0 || deleteConflicts.length > 0) {
EditorManager.focusEditor();
}
// (Any errors that ocurred during presentConflicts() have already
// shown UI & been dismissed, so there's no fail() handler here)
}
});
});
dialogOpen = false;
var i;
for (i = 0; i < plugins.length; i++) {
var plugin = plugins[i];
plugin.done();
}
// Ty TODO: disabled for now while file switching is disabled in _handleItemFocus
//JSLintUtils.setEnabled(true);
// Make sure Smart Autocomplete knows its popup is getting closed (in cases where there's no
// editor to give focus to below, it won't notice otherwise).
this.$searchField.trigger("lostFocus");
EditorManager.focusEditor();
// Closing the dialog is a little tricky (see #1384): some Smart Autocomplete code may run later (e.g.
// (because it's a later handler of the event that just triggered _close()), and that code expects to
// find metadata that it stuffed onto the DOM node earlier. But $.remove() strips that metadata.
// So, to hide the dialog immediately it's only safe to remove using raw DOM APIs:
this.dialog[0].parentNode.removeChild(this.dialog[0]);
var self = this;
setTimeout(function () {
// Now that it's safe, call the real jQuery API to clear the metadata & prevent a memory leak
self.dialog.remove();
}, 0);
$(".smart_autocomplete_container").remove();
$(window.document).off("mousedown", this.handleDocumentMouseDown);
};
$(this).triggerHandler("close");
function doRemove() {
self._$root.remove();
result.resolve();
}
if (animate) {
AnimationUtils.animateUsingClass(this._$root.get(0), "offscreen")
.done(doRemove);
} else {
doRemove();
}
EditorManager.focusEditor();
return result.promise();
};
var clickCallback = function () {
if ($selectedRow) {
$selectedRow.removeClass("selected");
}
$row.addClass("selected");
$selectedRow = $row;
var editor = EditorManager.getCurrentFullEditor();
editor.setCursorPos(item.line - 1, item.character - 1);
EditorManager.focusEditor();
};
$row.click(clickCallback);
FindInFilesDialog.prototype._close = function (value) {
if (this.closed) {
return;
}
this.closed = true;
this.modalBar.close();
EditorManager.focusEditor();
this.result.resolve(value);
};
FindInFilesDialog.prototype._close = function (value) {
if (this.closed) {
return;
}
this.closed = true;
this.modalBar.close();
EditorManager.focusEditor();
this.result.resolve(value);
};