Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to have no part of the file name pre-filled #45

Open
bdougherty opened this issue Jan 16, 2018 · 4 comments
Open

Add option to have no part of the file name pre-filled #45

bdougherty opened this issue Jan 16, 2018 · 4 comments

Comments

@bdougherty
Copy link

There doesn't seem to be a way to have just the path show up in the field. I find that most of the time, the filled in file extension is not what I want.

{
	"newFile.defaultBaseFileName": "",
	"newFile.defaultFileExtension": ""
}

I set those options but the file extension is still filled in.

@dkundel
Copy link
Owner

dkundel commented Jan 17, 2018

I think the VS Code extension API falls back to the default value in that case. The defaultFileExtension should only be set atm if you don't have any file open. Otherwise it should always use the same extension as the current file which at least for me works great in most cases. There are rare cases where I have to change it.

I'm happy to merge a PR to accept "" as a valid option. Maybe this should be combined with a new option "disableSmartExtension" to turn off the extension guessing if desired.

Cheers,
Dominik

@Telokis
Copy link
Collaborator

Telokis commented Mar 9, 2018

@bdougherty Any feedback on dkundel's answer?

@bdougherty
Copy link
Author

The disableSmartExtension option sounds like a good solution to me.

@Telokis
Copy link
Collaborator

Telokis commented May 13, 2018

So, let me recap:

  • Add an option named disableSmartExtension which will prevent the extension from being deducted from the current file. (
    const ext: string = path.extname(currentFileName) || defaultExtension;
    )
  • Don't forget to update the way we find selectionBoundsForFileName (
    const selectionBoundsForFileName: [number, number] = [
    defaultFileValue.lastIndexOf(path.sep) + 1,
    defaultFileValue.lastIndexOf('.'),
    ];
    ) to have nothing selected in that case. (Otherwise it would select the directory name which is not very user-friendly)

If someone feels like doing this, it's not that hard to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants