Skip to content

"Move to File" refactor says it will overwrite existing files even though it adds to them #63161

Closed

Description

@stephane-archer

move to file should allow to move a class to an already existing file without overwriting it's content
Image

Activity

  1. added
    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
    on Apr 12, 2026
  2. FMorschel commented on Apr 12, 2026

    @FMorschel
    Contributor

    This is already possible but there is a VS Code bug on the UI.

    CC @DanTup which issue was it?

  3. DanTup commented on Apr 12, 2026

    @DanTup
    Collaborator

    Yeah, I believe that if you choose an existing file, you might see a prompt about "overwring the file" (which is built-in functionality from VS Code/Electron or the OS depending on the kind of file dialog being shown), but it will not be overwritten, the content will be inserted as expected.

    Related issues are:

    The VS Code issue was unfortunately closed (I think because of limitations in Electron rather than disagreement with the issue).

    I think the best we can do is prompt and ask if you want to move to a new file or existing file after you select this fix, and then use the corresponding API to avoid the prompt. However it does mean if you choose the option to move to a "new file" and then select an existing file, you'd still see the (incorrect) warning. The alternative to that is not using the OSes file-picked at all, and implementing our own in the quick-input boxes, but given how wonky I find VS Code's own implementation of that (which is used when you're connected to a remote), I don't think that would be the best experience.

  4. changed the title [-]move to file should allow to move a class to an already existing file without overwriting it's content[/-] [+]"Move to File" refactor says it will overwrite existing files even though it adds to them[/+] on Apr 12, 2026
  5. DanTup commented on Apr 12, 2026

    @DanTup
    Collaborator

    I was going to keep this issue open to track this, however this bug is entirely VS Code-specific. Another LSP client could implement this in a different way - so I'll close this in favour of Dart-Code/Dart-Code#5066

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions