mrmlnc / vscode-duplicate

:electric_plug: Ability to duplicate files in VS Code.
https://goo.gl/LSnrBW
MIT License
52 stars 16 forks source link

Feature: Preserve file extension when duplicating files #45

Open Epigene opened 6 years ago

Epigene commented 6 years ago

VSCode Version: 1.20.1 OS Version: macOS High Sierra 10.13.2 Settings: https://gist.github.com/Epigene/a65bbf5e88d847b5e0622d42019fb678 Wrongly opened issue in VSC repo: https://github.com/Microsoft/vscode/issues/44254

Needed behavior: When duplicating a file it would be nice to have it append the "-copy" just before the file extension.

Current behavior: Duplication overrides file extension with "-copy".

Discussion: As can be seen in the example image below, I choose to duplicate a file named "calendar.apib" and the default duplicate file-name is "calendar-copy" where "calendar-copy.apib" would be much more useful. bad_dup

mrmlnc commented 6 years ago

Hello, @Epigene,

Sorry for delay. By default, the extension remains unchanged.

But if the extension does not match the original one, it will be changed:

Do you want the file extension to be displayed completely always?

Epigene commented 6 years ago

I never realised that is the behaviour. 😅 A config option that toggles whether the file extension is displayed would be nice.

btisdall commented 6 years ago

Hi, thanks for the extension! It looks like duplication doesn't work as expected if the filename contains more than one period (which is not an uncommon idiom in the *nix world).

How to reproduce:

  1. Create foo.dev.json
  2. Hit Duplicate file or directory – the new filename is displayed as foo-copy (ie minus the .dev.json suffix).
  3. Enter foo.test

Expected filename: foo.test.json Actual filename: foo.test

notpushkin commented 4 years ago

IMO a better option (if possible with Code APIs) would be to preserve extension(s) while selecting the filename part in the prompt, i. e. for file foo.d.ts a prompt [foo].d.ts ([] denoting a selection) is presented, from where user can:

I can work out a PR if this kind of functionality is okay with you.