_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q17400 | _itemsPerPage | train | function _itemsPerPage() {
var itemsPerPage = 1,
$items = self.$hintMenu.find("li"),
$view = self.$hintMenu.find("ul.dropdown-menu"),
itemHeight;
if ($items.length !== 0) {
itemHeight = $($items[0]).height();
if (it... | javascript | {
"resource": ""
} |
q17401 | stripQuotes | train | function stripQuotes(string) {
if (string) {
if (/^['"]$/.test(string.charAt(0))) {
string = string.substr(1);
}
if (/^['"]$/.test(string.substr(-1, 1))) {
string = string.substr(0, string.length - 1);
}
}
return str... | javascript | {
"resource": ""
} |
q17402 | add | train | function add() {
var root = FileUtils.stripTrailingSlash(ProjectManager.getProjectRoot().fullPath),
recentProjects = getRecentProjects(),
index = recentProjects.indexOf(root);
if (index !== -1) {
recentProjects.splice(index, 1);
}
recentProjects.unshi... | javascript | {
"resource": ""
} |
q17403 | checkHovers | train | function checkHovers(pageX, pageY) {
$dropdown.children().each(function () {
var offset = $(this).offset(),
width = $(this).outerWidth(),
height = $(this).outerHeight();
if (pageX >= offset.left && pageX <= offset.left + width &&
page... | javascript | {
"resource": ""
} |
q17404 | renderDelete | train | function renderDelete() {
return $("<div id='recent-folder-delete' class='trash-icon'>×</div>")
.mouseup(function (e) {
// Don't let the click bubble upward.
e.stopPropagation();
// Remove the project from the preferences.
var re... | javascript | {
"resource": ""
} |
q17405 | selectNextItem | train | function selectNextItem(direction) {
var $links = $dropdown.find("a"),
index = $dropdownItem ? $links.index($dropdownItem) : (direction > 0 ? -1 : 0),
$newItem = $links.eq((index + direction) % $links.length);
if ($dropdownItem) {
$dropdownItem.removeClass("sele... | javascript | {
"resource": ""
} |
q17406 | removeSelectedItem | train | function removeSelectedItem(e) {
var recentProjects = getRecentProjects(),
$cacheItem = $dropdownItem,
index = recentProjects.indexOf($cacheItem.data("path"));
// When focus is not on project item
if (index === -1) {
return false;
}
// remove... | javascript | {
"resource": ""
} |
q17407 | keydownHook | train | function keydownHook(event) {
var keyHandled = false;
switch (event.keyCode) {
case KeyEvent.DOM_VK_UP:
selectNextItem(-1);
keyHandled = true;
break;
case KeyEvent.DOM_VK_DOWN:
selectNextItem(+1);
keyHandled = true;
... | javascript | {
"resource": ""
} |
q17408 | cleanupDropdown | train | function cleanupDropdown() {
$("html").off("click", closeDropdown);
$("#project-files-container").off("scroll", closeDropdown);
$("#titlebar .nav").off("click", closeDropdown);
$dropdown = null;
MainViewManager.focusActivePane();
$(window).off("keydown", keydownHook);
... | javascript | {
"resource": ""
} |
q17409 | parsePath | train | function parsePath(path) {
var lastSlash = path.lastIndexOf("/"), folder, rest;
if (lastSlash === path.length - 1) {
lastSlash = path.slice(0, path.length - 1).lastIndexOf("/");
}
if (lastSlash >= 0) {
rest = " - " + (lastSlash ? path.slice(0, lastSlash) : "/");
... | javascript | {
"resource": ""
} |
q17410 | renderList | train | function renderList() {
var recentProjects = getRecentProjects(),
currentProject = FileUtils.stripTrailingSlash(ProjectManager.getProjectRoot().fullPath),
templateVars = {
projectList : [],
Strings : Strings
};
recentProjects.for... | javascript | {
"resource": ""
} |
q17411 | showDropdown | train | function showDropdown(position) {
// If the dropdown is already visible, just return (so the root click handler on html
// will close it).
if ($dropdown) {
return;
}
Menus.closeAll();
$dropdown = $(renderList())
.css({
left: posit... | javascript | {
"resource": ""
} |
q17412 | handleKeyEvent | train | function handleKeyEvent() {
if (!$dropdown) {
if (!SidebarView.isVisible()) {
SidebarView.show();
}
$("#project-dropdown-toggle").trigger("click");
$dropdown.focus();
$links = $dropdown.find("a");
// By default, select the... | javascript | {
"resource": ""
} |
q17413 | _validateFrame | train | function _validateFrame(entry) {
var deferred = new $.Deferred(),
fileEntry = FileSystem.getFileForPath(entry.filePath);
if (entry.inMem) {
var indexInWS = MainViewManager.findInWorkingSet(entry.paneId, entry.filePath);
// Remove entry if InMemoryFile is not found in... | javascript | {
"resource": ""
} |
q17414 | _navigateBack | train | function _navigateBack() {
if (!jumpForwardStack.length) {
if (activePosNotSynced) {
currentEditPos = new NavigationFrame(EditorManager.getCurrentFullEditor(), {ranges: EditorManager.getCurrentFullEditor()._codeMirror.listSelections()});
jumpForwardStack.push(currentE... | javascript | {
"resource": ""
} |
q17415 | _navigateForward | train | function _navigateForward() {
var navFrame = jumpForwardStack.pop();
if (!navFrame) {
return;
}
// Check if the poped frame is the current active frame or doesn't have any valid marker information
// if true, jump again
if (navFrame === curre... | javascript | {
"resource": ""
} |
q17416 | _initNavigationMenuItems | train | function _initNavigationMenuItems() {
var menu = Menus.getMenu(Menus.AppMenuBar.NAVIGATE_MENU);
menu.addMenuItem(NAVIGATION_JUMP_BACK, "", Menus.AFTER, Commands.NAVIGATE_PREV_DOC);
menu.addMenuItem(NAVIGATION_JUMP_FWD, "", Menus.AFTER, NAVIGATION_JUMP_BACK);
} | javascript | {
"resource": ""
} |
q17417 | _initNavigationCommands | train | function _initNavigationCommands() {
CommandManager.register(Strings.CMD_NAVIGATE_BACKWARD, NAVIGATION_JUMP_BACK, _navigateBack);
CommandManager.register(Strings.CMD_NAVIGATE_FORWARD, NAVIGATION_JUMP_FWD, _navigateForward);
commandJumpBack = CommandManager.get(NAVIGATION_JUMP_BACK);
comm... | javascript | {
"resource": ""
} |
q17418 | _captureFrame | train | function _captureFrame(editor) {
// Capture the active position now if it was not captured earlier
if ((activePosNotSynced || !jumpBackwardStack.length) && !jumpInProgress) {
jumpBackwardStack.push(new NavigationFrame(editor, {ranges: editor._codeMirror.listSelections()}));
}
} | javascript | {
"resource": ""
} |
q17419 | _backupLiveMarkers | train | function _backupLiveMarkers(frames, editor) {
var index, frame;
for (index in frames) {
frame = frames[index];
if (frame.cm === editor._codeMirror) {
frame._handleEditorDestroy();
}
}
} | javascript | {
"resource": ""
} |
q17420 | _handleExternalChange | train | function _handleExternalChange(evt, doc) {
if (doc) {
_removeBackwardFramesForFile(doc.file);
_removeForwardFramesForFile(doc.file);
_validateNavigationCmds();
}
} | javascript | {
"resource": ""
} |
q17421 | _reinstateMarkers | train | function _reinstateMarkers(editor, frames) {
var index, frame;
for (index in frames) {
frame = frames[index];
if (!frame.cm && frame.filePath === editor.document.file._path) {
frame._reinstateMarkers(editor);
}
}
} | javascript | {
"resource": ""
} |
q17422 | _handleActiveEditorChange | train | function _handleActiveEditorChange(event, current, previous) {
if (previous && previous._paneId) { // Handle only full editors
previous.off("beforeSelectionChange", _recordJumpDef);
_captureFrame(previous);
_validateNavigationCmds();
}
if (current && ... | javascript | {
"resource": ""
} |
q17423 | repositionResizer | train | function repositionResizer(elementSize) {
var resizerPosition = elementSize || 1;
if (position === POSITION_RIGHT || position === POSITION_BOTTOM) {
$resizer.css(resizerCSSPosition, resizerPosition);
}
} | javascript | {
"resource": ""
} |
q17424 | _enqueueChange | train | function _enqueueChange(changedPath, stats) {
_pendingChanges[changedPath] = stats;
if (!_changeTimeout) {
_changeTimeout = window.setTimeout(function () {
if (_changeCallback) {
Object.keys(_pendingChanges).forEach(function (path) {
... | javascript | {
"resource": ""
} |
q17425 | _fileWatcherChange | train | function _fileWatcherChange(evt, event, parentDirPath, entryName, statsObj) {
var change;
switch (event) {
case "changed":
// an existing file/directory was modified; stats are passed if available
var fsStats;
if (statsObj) {
fsStats = new File... | javascript | {
"resource": ""
} |
q17426 | _mapError | train | function _mapError(err) {
if (!err) {
return null;
}
switch (err) {
case appshell.fs.ERR_INVALID_PARAMS:
return FileSystemError.INVALID_PARAMS;
case appshell.fs.ERR_NOT_FOUND:
return FileSystemError.NOT_FOUND;
case appshell.fs.ERR_CANT... | javascript | {
"resource": ""
} |
q17427 | showOpenDialog | train | function showOpenDialog(allowMultipleSelection, chooseDirectories, title, initialPath, fileTypes, callback) {
appshell.fs.showOpenDialog(allowMultipleSelection, chooseDirectories, title, initialPath, fileTypes, _wrap(callback));
} | javascript | {
"resource": ""
} |
q17428 | showSaveDialog | train | function showSaveDialog(title, initialPath, proposedNewFilename, callback) {
appshell.fs.showSaveDialog(title, initialPath, proposedNewFilename, _wrap(callback));
} | javascript | {
"resource": ""
} |
q17429 | stat | train | function stat(path, callback) {
appshell.fs.stat(path, function (err, stats) {
if (err) {
callback(_mapError(err));
} else {
var options = {
isFile: stats.isFile(),
mtime: stats.mtime,
size: stats... | javascript | {
"resource": ""
} |
q17430 | exists | train | function exists(path, callback) {
stat(path, function (err) {
if (err) {
if (err === FileSystemError.NOT_FOUND) {
callback(null, false);
} else {
callback(err);
}
return;
}
... | javascript | {
"resource": ""
} |
q17431 | mkdir | train | function mkdir(path, mode, callback) {
if (typeof mode === "function") {
callback = mode;
mode = parseInt("0755", 8);
}
appshell.fs.makedir(path, mode, function (err) {
if (err) {
callback(_mapError(err));
} else {
s... | javascript | {
"resource": ""
} |
q17432 | rename | train | function rename(oldPath, newPath, callback) {
appshell.fs.rename(oldPath, newPath, _wrap(callback));
} | javascript | {
"resource": ""
} |
q17433 | doReadFile | train | function doReadFile(stat) {
if (stat.size > (FileUtils.MAX_FILE_SIZE)) {
callback(FileSystemError.EXCEEDS_MAX_FILE_SIZE);
} else {
appshell.fs.readFile(path, encoding, function (_err, _data, encoding, preserveBOM) {
if (_err) {
... | javascript | {
"resource": ""
} |
q17434 | moveToTrash | train | function moveToTrash(path, callback) {
appshell.fs.moveToTrash(path, function (err) {
callback(_mapError(err));
});
} | javascript | {
"resource": ""
} |
q17435 | watchPath | train | function watchPath(path, ignored, callback) {
if (_isRunningOnWindowsXP) {
callback(FileSystemError.NOT_SUPPORTED);
return;
}
appshell.fs.isNetworkDrive(path, function (err, isNetworkDrive) {
if (err || isNetworkDrive) {
if (isNetworkDrive) {
... | javascript | {
"resource": ""
} |
q17436 | unwatchPath | train | function unwatchPath(path, ignored, callback) {
_nodeDomain.exec("unwatchPath", path)
.then(callback, callback);
} | javascript | {
"resource": ""
} |
q17437 | reloadDoc | train | function reloadDoc(doc) {
var promise = FileUtils.readAsText(doc.file);
promise.done(function (text, readTimestamp) {
doc.refreshText(text, readTimestamp);
});
promise.fail(function (error) {
console.log("Error reloading contents of " + doc.file.fullPath, error)... | javascript | {
"resource": ""
} |
q17438 | parsePersonString | train | function parsePersonString(obj) {
if (typeof (obj) === "string") {
var parts = _personRegex.exec(obj);
// No regex match, so we just synthesize an object with an opaque name string
if (!parts) {
return {
name: obj
};
} else {
var r... | javascript | {
"resource": ""
} |
q17439 | containsWords | train | function containsWords(wordlist, str) {
var i;
var matches = [];
for (i = 0; i < wordlist.length; i++) {
var re = new RegExp("\\b" + wordlist[i] + "\\b", "i");
if (re.exec(str)) {
matches.push(wordlist[i]);
}
}
return matches;
} | javascript | {
"resource": ""
} |
q17440 | findCommonPrefix | train | function findCommonPrefix(extractDir, callback) {
fs.readdir(extractDir, function (err, files) {
ignoredFolders.forEach(function (folder) {
var index = files.indexOf(folder);
if (index !== -1) {
files.splice(index, 1);
}
});
if (err) {
... | javascript | {
"resource": ""
} |
q17441 | validatePackageJSON | train | function validatePackageJSON(path, packageJSON, options, callback) {
var errors = [];
if (fs.existsSync(packageJSON)) {
fs.readFile(packageJSON, {
encoding: "utf8"
}, function (err, data) {
if (err) {
callback(err, null, null);
return;
... | javascript | {
"resource": ""
} |
q17442 | extractAndValidateFiles | train | function extractAndValidateFiles(zipPath, extractDir, options, callback) {
var unzipper = new DecompressZip(zipPath);
unzipper.on("error", function (err) {
// General error to report for problems reading the file
callback(null, {
errors: [[Errors.INVALID_ZIP_FILE, zipPath, err]]
... | javascript | {
"resource": ""
} |
q17443 | validate | train | function validate(path, options, callback) {
options = options || {};
fs.exists(path, function (doesExist) {
if (!doesExist) {
callback(null, {
errors: [[Errors.NOT_FOUND_ERR, path]]
});
return;
}
temp.mkdir("bracketsPackage_", function... | javascript | {
"resource": ""
} |
q17444 | SelectionFold | train | function SelectionFold(cm, start) {
if (!cm.somethingSelected()) {
return;
}
var from = cm.getCursor("from"),
to = cm.getCursor("to");
if (from.line === start.line) {
return {from: from, to: to};
}
} | javascript | {
"resource": ""
} |
q17445 | _send | train | function _send(method, signature, varargs) {
if (!_socket) {
console.log("You must connect to the WebSocket before sending messages.");
// FUTURE: Our current implementation closes and re-opens an inspector connection whenever
// a new HTML file is selected. If done quickly ... | javascript | {
"resource": ""
} |
q17446 | _onError | train | function _onError(error) {
if (_connectDeferred) {
_connectDeferred.reject();
_connectDeferred = null;
}
exports.trigger("error", error);
} | javascript | {
"resource": ""
} |
q17447 | disconnect | train | function disconnect() {
var deferred = new $.Deferred(),
promise = deferred.promise();
if (_socket && (_socket.readyState === WebSocket.OPEN)) {
_socket.onclose = function () {
// trigger disconnect event
_onDisconnect();
deferred... | javascript | {
"resource": ""
} |
q17448 | connect | train | function connect(socketURL) {
disconnect().done(function () {
_socket = new WebSocket(socketURL);
_socket.onmessage = _onMessage;
_socket.onopen = _onConnect;
_socket.onclose = _onDisconnect;
_socket.onerror = _onError;
});
} | javascript | {
"resource": ""
} |
q17449 | connectToURL | train | function connectToURL(url) {
if (_connectDeferred) {
// reject an existing connection attempt
_connectDeferred.reject("CANCEL");
}
var deferred = new $.Deferred();
_connectDeferred = deferred;
var promise = getDebuggableWindows();
promise.done(func... | javascript | {
"resource": ""
} |
q17450 | showBusyIndicator | train | function showBusyIndicator(updateCursor) {
if (!_init) {
console.error("StatusBar API invoked before status bar created");
return;
}
if (updateCursor) {
_busyCursor = true;
$("*").addClass("busyCursor");
}
$busyIndicator.addClass(... | javascript | {
"resource": ""
} |
q17451 | addIndicator | train | function addIndicator(id, indicator, visible, style, tooltip, insertBefore) {
if (!_init) {
console.error("StatusBar API invoked before status bar created");
return;
}
indicator = indicator || window.document.createElement("div");
tooltip = tooltip || "";
... | javascript | {
"resource": ""
} |
q17452 | updateIndicator | train | function updateIndicator(id, visible, style, tooltip) {
if (!_init && !!brackets.test) {
console.error("StatusBar API invoked before status bar created");
return;
}
var $indicator = $("#" + id.replace(_indicatorIDRegexp, "-"));
if ($indicator) {
if ... | javascript | {
"resource": ""
} |
q17453 | updateScrollbars | train | function updateScrollbars(theme) {
theme = theme || {};
if (prefs.get("themeScrollbars")) {
var scrollbar = (theme.scrollbar || []).join(" ");
$scrollbars.text(scrollbar || "");
} else {
$scrollbars.text("");
}
} | javascript | {
"resource": ""
} |
q17454 | updateThemes | train | function updateThemes(cm) {
var newTheme = prefs.get("theme"),
cmTheme = (cm.getOption("theme") || "").replace(/[\s]*/, ""); // Normalize themes string
// Check if the editor already has the theme applied...
if (cmTheme === newTheme) {
return;
}
// Setu... | javascript | {
"resource": ""
} |
q17455 | getSelectedItem | train | function getSelectedItem() {
// Prefer file tree context, then file tree selection, else use working set
var selectedEntry = getFileTreeContext();
if (!selectedEntry) {
selectedEntry = model.getSelected();
}
if (!selectedEntry) {
selectedEntry = MainViewMa... | javascript | {
"resource": ""
} |
q17456 | setBaseUrl | train | function setBaseUrl(projectBaseUrl) {
var context = _getProjectViewStateContext();
projectBaseUrl = model.setBaseUrl(projectBaseUrl);
PreferencesManager.setViewState("project.baseUrl", projectBaseUrl, context);
} | javascript | {
"resource": ""
} |
q17457 | addWelcomeProjectPath | train | function addWelcomeProjectPath(path) {
var welcomeProjects = ProjectModel._addWelcomeProjectPath(path,
PreferencesManager.getViewState("welcomeProjects"));
PreferencesManager.setViewState("welcomeProjects", welcomeProjects);
} | javascript | {
"resource": ""
} |
q17458 | _getFallbackProjectPath | train | function _getFallbackProjectPath() {
var fallbackPaths = [],
recentProjects = PreferencesManager.getViewState("recentProjects") || [],
deferred = new $.Deferred();
// Build ordered fallback path array
if (recentProjects.length > 1) {
// *Most* recent project ... | javascript | {
"resource": ""
} |
q17459 | openProject | train | function openProject(path) {
var result = new $.Deferred();
// Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't
// actually close any documents even on success; we'll do that manually after the user also oks
// the folder-browse dialog.
... | javascript | {
"resource": ""
} |
q17460 | createNewItem | train | function createNewItem(baseDir, initialName, skipRename, isFolder) {
baseDir = model.getDirectoryInProject(baseDir);
if (skipRename) {
if(isFolder) {
return model.createAtPath(baseDir + initialName + "/");
}
return model.createAtPath(baseDir + initial... | javascript | {
"resource": ""
} |
q17461 | deleteItem | train | function deleteItem(entry) {
var result = new $.Deferred();
entry.moveToTrash(function (err) {
if (!err) {
DocumentManager.notifyPathDeleted(entry.fullPath);
result.resolve();
} else {
_showErrorDialog(ERR_TYPE_DELETE, entry.isDire... | javascript | {
"resource": ""
} |
q17462 | _formatCountable | train | function _formatCountable(number, singularStr, pluralStr) {
return StringUtils.format(number > 1 ? pluralStr : singularStr, number);
} | javascript | {
"resource": ""
} |
q17463 | _updateLanguageInfo | train | function _updateLanguageInfo(editor) {
var doc = editor.document,
lang = doc.getLanguage();
// Show the current language as button title
languageSelect.$button.text(lang.getName());
} | javascript | {
"resource": ""
} |
q17464 | _updateFileInfo | train | function _updateFileInfo(editor) {
var lines = editor.lineCount();
$fileInfo.text(_formatCountable(lines, Strings.STATUSBAR_LINE_COUNT_SINGULAR, Strings.STATUSBAR_LINE_COUNT_PLURAL));
} | javascript | {
"resource": ""
} |
q17465 | _updateIndentType | train | function _updateIndentType(fullPath) {
var indentWithTabs = Editor.getUseTabChar(fullPath);
$indentType.text(indentWithTabs ? Strings.STATUSBAR_TAB_SIZE : Strings.STATUSBAR_SPACES);
$indentType.attr("title", indentWithTabs ? Strings.STATUSBAR_INDENT_TOOLTIP_SPACES : Strings.STATUSBAR_INDENT_TOOL... | javascript | {
"resource": ""
} |
q17466 | _toggleIndentType | train | function _toggleIndentType() {
var current = EditorManager.getActiveEditor(),
fullPath = current && current.document.file.fullPath;
Editor.setUseTabChar(!Editor.getUseTabChar(fullPath), fullPath);
_updateIndentType(fullPath);
_updateIndentSize(fullPath);
} | javascript | {
"resource": ""
} |
q17467 | _changeIndentWidth | train | function _changeIndentWidth(fullPath, value) {
$indentWidthLabel.removeClass("hidden");
$indentWidthInput.addClass("hidden");
// remove all event handlers from the input field
$indentWidthInput.off("blur keyup");
// restore focus to the editor
MainViewManager.focusActiv... | javascript | {
"resource": ""
} |
q17468 | _onActiveEditorChange | train | function _onActiveEditorChange(event, current, previous) {
if (previous) {
previous.off(".statusbar");
previous.document.off(".statusbar");
previous.document.releaseRef();
}
if (!current) {
StatusBar.hideAllPanes();
} else {
va... | javascript | {
"resource": ""
} |
q17469 | _populateLanguageDropdown | train | function _populateLanguageDropdown() {
// Get all non-binary languages
var languages = _.values(LanguageManager.getLanguages()).filter(function (language) {
return !language.isBinary();
});
// sort dropdown alphabetically
languages.sort(function (a, b) {
... | javascript | {
"resource": ""
} |
q17470 | _changeEncodingAndReloadDoc | train | function _changeEncodingAndReloadDoc(document) {
var promise = document.reload();
promise.done(function (text, readTimestamp) {
encodingSelect.$button.text(document.file._encoding);
// Store the preferred encoding in the state
var projectRoot = ProjectManager.getProje... | javascript | {
"resource": ""
} |
q17471 | createFunctionList | train | function createFunctionList() {
var doc = DocumentManager.getCurrentDocument();
if (!doc) {
return;
}
var functionList = [];
var docText = doc.getText();
var lines = docText.split("\n");
var functions = JSUtils.findAllMatchingFunctionsInText(docText, ... | javascript | {
"resource": ""
} |
q17472 | rangeEqualsSelection | train | function rangeEqualsSelection(range, selection) {
return range.from.line === selection.start.line && range.from.ch === selection.start.ch &&
range.to.line === selection.end.line && range.to.ch === selection.end.ch;
} | javascript | {
"resource": ""
} |
q17473 | isInViewStateSelection | train | function isInViewStateSelection(range, viewState) {
if (!viewState || !viewState.selections) {
return false;
}
return viewState.selections.some(function (selection) {
return rangeEqualsSelection(range, selection);
});
} | javascript | {
"resource": ""
} |
q17474 | saveLineFolds | train | function saveLineFolds(editor) {
var saveFolds = prefs.getSetting("saveFoldStates");
if (!editor || !saveFolds) {
return;
}
var folds = editor._codeMirror._lineFolds || {};
var path = editor.document.file.fullPath;
if (Object.keys(folds).length) {
... | javascript | {
"resource": ""
} |
q17475 | collapseCurrent | train | function collapseCurrent() {
var editor = EditorManager.getFocusedEditor();
if (!editor) {
return;
}
var cm = editor._codeMirror;
var cursor = editor.getCursorPos(), i;
// Move cursor up until a collapsible line is found
for (i = cursor.line; i >= 0; i... | javascript | {
"resource": ""
} |
q17476 | expandCurrent | train | function expandCurrent() {
var editor = EditorManager.getFocusedEditor();
if (editor) {
var cursor = editor.getCursorPos(), cm = editor._codeMirror;
cm.unfoldCode(cursor.line);
}
} | javascript | {
"resource": ""
} |
q17477 | expandAll | train | function expandAll() {
var editor = EditorManager.getFocusedEditor();
if (editor) {
var cm = editor._codeMirror;
CodeMirror.commands.unfoldAll(cm);
}
} | javascript | {
"resource": ""
} |
q17478 | setupGutterEventListeners | train | function setupGutterEventListeners(editor) {
var cm = editor._codeMirror;
$(editor.getRootElement()).addClass("folding-enabled");
cm.setOption("foldGutter", {onGutterClick: onGutterClick});
$(cm.getGutterElement()).on({
mouseenter: function () {
if (prefs.get... | javascript | {
"resource": ""
} |
q17479 | removeGutters | train | function removeGutters(editor) {
Editor.unregisterGutter(GUTTER_NAME);
$(editor.getRootElement()).removeClass("folding-enabled");
CodeMirror.defineOption("foldGutter", false, null);
} | javascript | {
"resource": ""
} |
q17480 | onActiveEditorChanged | train | function onActiveEditorChanged(event, current, previous) {
if (current && !current._codeMirror._lineFolds) {
enableFoldingInEditor(current);
}
if (previous) {
saveLineFolds(previous);
}
} | javascript | {
"resource": ""
} |
q17481 | deinit | train | function deinit() {
_isInitialized = false;
KeyBindingManager.removeBinding(collapseKey);
KeyBindingManager.removeBinding(expandKey);
KeyBindingManager.removeBinding(collapseAllKey);
KeyBindingManager.removeBinding(expandAllKey);
KeyBindingManager.removeBinding(collapseA... | javascript | {
"resource": ""
} |
q17482 | init | train | function init() {
_isInitialized = true;
foldCode.init();
foldGutter.init();
// Many CodeMirror modes specify which fold helper should be used for that language. For a few that
// don't, we register helpers explicitly here. We also register a global helper for generic indent-ba... | javascript | {
"resource": ""
} |
q17483 | watchPrefsForChanges | train | function watchPrefsForChanges() {
prefs.prefsObject.on("change", function (e, data) {
if (data.ids.indexOf("enabled") > -1) {
// Check if enabled state mismatches whether code-folding is actually initialized (can't assume
// since preference change events can occur wh... | javascript | {
"resource": ""
} |
q17484 | init | train | function init(domainManager) {
if (!domainManager.hasDomain("fileWatcher")) {
domainManager.registerDomain("fileWatcher", {major: 0, minor: 1});
}
domainManager.registerCommand(
"fileWatcher",
"watchPath",
watcherManager.watchPath,
false,
"Start watching a fi... | javascript | {
"resource": ""
} |
q17485 | _write | train | function _write(filePath, json) {
var result = $.Deferred(),
_file = FileSystem.getFileForPath(filePath);
if (_file) {
var content = JSON.stringify(json);
FileUtils.writeText(_file, content, true)
.done(function () {
result.resolv... | javascript | {
"resource": ""
} |
q17486 | collectDuplicates | train | function collectDuplicates(value) {
if (value == null || typeof value !== 'object') {
return;
}
const metadata = metadataForVal.get(value);
// Only consider duplicates with hashes longer than 2 (excludes [] and {}).
if (metadata && metadata.value !== value && metadata.hash.length > 2) {
... | javascript | {
"resource": ""
} |
q17487 | printJSCode | train | function printJSCode(isDupedVar, depth, value) {
if (value == null || typeof value !== 'object') {
return JSON.stringify(value);
}
// Only use variable references at depth beyond the top level.
if (depth !== '') {
const metadata = metadataForVal.get(value);
if (metadata && metadata.isD... | javascript | {
"resource": ""
} |
q17488 | mapModule | train | function mapModule(state, module) {
var moduleMap = state.opts.map || {};
if (moduleMap.hasOwnProperty(module)) {
return moduleMap[module];
}
// Jest understands the haste module system, so leave modules intact.
if (process.env.NODE_ENV === 'test') {
return;
}
return './' + path.basename(module);
... | javascript | {
"resource": ""
} |
q17489 | cache | train | function cache (options) {
if (is.bool(options)) {
if (options) {
// Default cache settings of 50MB, 20 files, 100 items
return sharp.cache(50, 20, 100);
} else {
return sharp.cache(0, 0, 0);
}
} else if (is.object(options)) {
return sharp.cache(options.memory, options.files, optio... | javascript | {
"resource": ""
} |
q17490 | extractChannel | train | function extractChannel (channel) {
if (channel === 'red') {
channel = 0;
} else if (channel === 'green') {
channel = 1;
} else if (channel === 'blue') {
channel = 2;
}
if (is.integer(channel) && is.inRange(channel, 0, 4)) {
this.options.extractChannel = channel;
} else {
throw new Error... | javascript | {
"resource": ""
} |
q17491 | _write | train | function _write (chunk, encoding, callback) {
/* istanbul ignore else */
if (Array.isArray(this.options.input.buffer)) {
/* istanbul ignore else */
if (is.buffer(chunk)) {
if (this.options.input.buffer.length === 0) {
const that = this;
this.on('finish', function () {
that.st... | javascript | {
"resource": ""
} |
q17492 | _flattenBufferIn | train | function _flattenBufferIn () {
if (this._isStreamInput()) {
this.options.input.buffer = Buffer.concat(this.options.input.buffer);
}
} | javascript | {
"resource": ""
} |
q17493 | clone | train | function clone () {
const that = this;
// Clone existing options
const clone = this.constructor.call();
clone.options = Object.assign({}, this.options);
// Pass 'finish' event to clone for Stream-based input
if (this._isStreamInput()) {
this.on('finish', function () {
// Clone inherits input data
... | javascript | {
"resource": ""
} |
q17494 | stats | train | function stats (callback) {
const that = this;
if (is.fn(callback)) {
if (this._isStreamInput()) {
this.on('finish', function () {
that._flattenBufferIn();
sharp.stats(that.options, callback);
});
} else {
sharp.stats(this.options, callback);
}
return this;
} else... | javascript | {
"resource": ""
} |
q17495 | toFile | train | function toFile (fileOut, callback) {
if (!fileOut || fileOut.length === 0) {
const errOutputInvalid = new Error('Missing output file path');
if (is.fn(callback)) {
callback(errOutputInvalid);
} else {
return Promise.reject(errOutputInvalid);
}
} else {
if (this.options.input.file ==... | javascript | {
"resource": ""
} |
q17496 | toBuffer | train | function toBuffer (options, callback) {
if (is.object(options)) {
if (is.bool(options.resolveWithObject)) {
this.options.resolveWithObject = options.resolveWithObject;
}
}
return this._pipeline(is.fn(options) ? options : callback);
} | javascript | {
"resource": ""
} |
q17497 | jpeg | train | function jpeg (options) {
if (is.object(options)) {
if (is.defined(options.quality)) {
if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
this.options.jpegQuality = options.quality;
} else {
throw new Error('Invalid quality (integer, 1-100) ' + options.quality);
... | javascript | {
"resource": ""
} |
q17498 | png | train | function png (options) {
if (is.object(options)) {
if (is.defined(options.progressive)) {
this._setBooleanOption('pngProgressive', options.progressive);
}
if (is.defined(options.compressionLevel)) {
if (is.integer(options.compressionLevel) && is.inRange(options.compressionLevel, 0, 9)) {
... | javascript | {
"resource": ""
} |
q17499 | webp | train | function webp (options) {
if (is.object(options) && is.defined(options.quality)) {
if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
this.options.webpQuality = options.quality;
} else {
throw new Error('Invalid quality (integer, 1-100) ' + options.quality);
}
}
if (... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.