DanTup · GitHub

When using the "Move to File" refactor, if you select an existing file you may see an overwrite prompt like these:

image

This is because we use the showSaveDialog API and that has this built-in.

If we switch to the showOpenDialog API, however that doesn't allow creating new files:

image

TypeScript is working around this by giving the user an option to choose "existing file" versus "new file" (as well as having a basic file search):

image

If you select "new file" but then choose an existing file, you'll see the same overwrite prompt. That's not great, but if you use the correct actions then it's not something you'd see. It's less confusing than what we currently have for Dart.

I filed microsoft/vscode#203326 about this but it was rejected for not getting 20 thumbs-ups in 60 days.

Some possible options:

  • Do nothing, consider this expected (albeit unwanted) behaviour
  • Produce two actions on the server, "Move to Existing File" and "Move to New File" with different kinds of input prompts (save + open) that map onto the two different VS Code native dialog APIs
  • Implement a custom file selection using the quick-pick API (similar to TypeScript above.. it could either be a full picker that browsers directories, or just a search/filter of all files in the workspace)
  • Keep the server the same, but change handling of the saveUri prompt to show a quick-pick that lets the user select from some options (which just trigger the appropriate native dialogs):
    • Move to (name inferred from the item being moved if there's only one)
    • Move to existing file
    • Move to new file
  • ???

Read the original on github.com ↗