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

Exclude file ext from initial selection when renaming a file. #7209

Merged
merged 1 commit into from
Mar 18, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be first index of "." instead? If I have e.g. "foo.css.erb" I'd just want to rename the "foo" part.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When renaming files like less-1.4.2.min.js, usually only the last part is considered an extension.

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