Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Zanqi/issue 1793: F2 key should be assigned to rename selected file/folder command. #1836

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/document/DocumentCommandHandlers.js
Expand Up @@ -236,8 +236,7 @@ define(function (require, exports, module) {
fullPath = commandData.fullPath;
}

return _doOpenWithOptionalPath(fullPath)
.always(EditorManager.focusEditor);
return _doOpenWithOptionalPath(fullPath);
}

/**
Expand Down Expand Up @@ -742,7 +741,11 @@ define(function (require, exports, module) {
}

function handleFileRename() {
ProjectManager.renameSelectedItem();
var promise = CommandManager.execute(Commands.NAVIGATE_SHOW_IN_FILE_TREE, {fileEntry: DocumentManager.getCurrentDocument().file});
promise
.done(function ($node) {
ProjectManager.renameSelectedItem();
});
}

/** Closes the window, then quits the app */
Expand Down Expand Up @@ -812,7 +815,7 @@ define(function (require, exports, module) {
}

function handleShowInTree() {
ProjectManager.showInTree(DocumentManager.getCurrentDocument().file);
return ProjectManager.showInTree(DocumentManager.getCurrentDocument().file);
}


Expand Down
4 changes: 3 additions & 1 deletion src/project/ProjectManager.js
Expand Up @@ -826,11 +826,13 @@ define(function (require, exports, module) {
}

function showInTree(fileEntry) {
_findTreeNode(fileEntry)
var promise = _findTreeNode(fileEntry);
promise
.done(function ($node) {
// jsTree will automatically expand parent nodes to ensure visible
_projectTree.jstree("select_node", $node, false);
});
return promise;
}


Expand Down
18 changes: 17 additions & 1 deletion src/project/SidebarView.js
Expand Up @@ -42,6 +42,7 @@ define(function (require, exports, module) {
Strings = require("strings"),
PreferencesManager = require("preferences/PreferencesManager"),
EditorManager = require("editor/EditorManager"),
KeyBindingManager = require("command/KeyBindingManager"),
Global = require("utils/Global");

var isSidebarClosed = false;
Expand Down Expand Up @@ -249,7 +250,18 @@ define(function (require, exports, module) {
e.preventDefault();
});
}


function _initSidebarKeyBinding() {
$sidebar.focus(function () {
KeyBindingManager.addBinding(Commands.FILE_RENAME, [{key: "F2", platform: "win"},
{key: "Enter", platform: "mac"}]);
});
$sidebar.blur(function (event) {
KeyBindingManager.removeBinding("F2", "win");
KeyBindingManager.removeBinding("Enter", "mac");
});
}

// Initialize items dependent on HTML DOM
AppInit.htmlReady(function () {
$sidebar = $("#sidebar");
Expand All @@ -259,9 +271,13 @@ define(function (require, exports, module) {
$projectTitle = $("#project-title");
$projectFilesContainer = $("#project-files-container");

// make sidebar focusable
$sidebar.attr("tabindex", "0");

// init
WorkingSetView.create($openFilesContainer);
_initSidebarResizer();
_initSidebarKeyBinding();
});

$(ProjectManager).on("projectOpen", _updateProjectTitle);
Expand Down
1 change: 0 additions & 1 deletion src/project/WorkingSetView.js
Expand Up @@ -176,7 +176,6 @@ define(function (require, exports, module) {

$newItem.mousedown(function (e) {
FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW);
e.preventDefault();
});

$newItem.hover(
Expand Down