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

Commit

Permalink
Exclude file ext from initial selection when renaming a file.
Browse files Browse the repository at this point in the history
This change performs the rename as usual through JSTree, then
grabs the DOM node and adjusts the selection on it after the fact.
This fixes issue #7019
  • Loading branch information
Kyle Sabo committed Mar 16, 2014
1 parent 8971aed commit 17e3703
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1807,8 +1807,13 @@ define(function (require, exports, module) {

// Since html_titles are enabled, we have to reset the text without markup.
// And we also need to explicitly escape all html-sensitive characters.
_projectTree.jstree("set_text", $selected, _.escape(entry.name));
var escapedName = _.escape(entry.name);
_projectTree.jstree("set_text", $selected, escapedName);
_projectTree.jstree("rename");
var indexOfExtension = escapedName.lastIndexOf('.');
if (indexOfExtension > 0) {
$selected.children(".jstree-rename-input")[0].setSelectionRange(0, indexOfExtension);
}
});
// No fail handler: silently no-op if file doesn't exist in tree
}
Expand Down

0 comments on commit 17e3703

Please sign in to comment.