-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Closed
Labels
feature-requestRequest for new features or functionalityRequest for new features or functionalityfile-explorerExplorer widget issuesExplorer widget issueshelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesverification-neededVerification of issue is requestedVerification of issue is requestedverifiedVerification succeededVerification succeeded
Milestone
Description
- VSCode Version: 1.22.0-insider
- OS Version: macOS 10.13.3
Currently VSCode increments suffix when copying a file. Copying file.1.ext makes file.2.ext. But there are cases when the version is specified in prefix not suffix, for instance when dealing with migrations we have files like 001-name.ext, copying this results in creating a file named 001-name.1.ext which is not the desired result.
It would be great if VSCode could detect and increment the prefix if needed. It also requires minimal changes to incrementFileName method to add the functionality.
function incrementFileName(name: string, isFolder: boolean): string {
// file.1.txt=>file.2.txt
if (!isFolder && name.match(/(.*\.)(\d+)(\..*)$/)) {
return name.replace(/(.*\.)(\d+)(\..*)$/, (match, g1?, g2?, g3?) => { return g1 + (parseInt(g2) + 1) + g3; });
}
// file.txt=>file.1.txt
const lastIndexOfDot = name.lastIndexOf('.');
if (!isFolder && lastIndexOfDot >= 0) {
return strings.format('{0}.1{1}', name.substr(0, lastIndexOfDot), name.substr(lastIndexOfDot));
}
// folder.1=>folder.2
if (isFolder && name.match(/(\d+)$/)) {
return name.replace(/(\d+)$/, (match: string, ...groups: any[]) => { return String(parseInt(groups[0]) + 1); });
}
// file/folder=>file.1/folder.1
return strings.format('{0}.1', name);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature-requestRequest for new features or functionalityRequest for new features or functionalityfile-explorerExplorer widget issuesExplorer widget issueshelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesverification-neededVerification of issue is requestedVerification of issue is requestedverifiedVerification succeededVerification succeeded