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

New File opens untitled editor #10868

Conversation

colin-grant-work
Copy link
Contributor

@colin-grant-work colin-grant-work commented Mar 10, 2022

What it does

Fixes #3354 by building on #10608, and moving the code necessary to handle untitled resources into core rather than plugin-ext.

How to test

  1. The New file keyboard shortcut and menu item should open an untitled editor without prompting immediately for a filename.
  2. You should be able to use that editor to type whatever you'd like.
  3. If you try to close the widget after adding content, it should prompt you to save
  4. If you try to save the widget, it should open a file picker with a location determined by the following considerations (at the time you created the widget)
    • If you had another editor open at the time, it should try to place the new file in the same folder.
    • If you had a URI selected in the navigator, it should try to place the file in that location (same folder if file, in the folder if a folder is selected)
    • If you have a workspace open, it should try to place the file in the (first) root
    • It should fall back to your home directory

Review checklist

Reminder for reviewers

@colin-grant-work colin-grant-work force-pushed the feature/open-untitled-editor branch 2 times, most recently from 5cb7e06 to 9472dfb Compare March 10, 2022 00:38
@msujew msujew self-requested a review March 14, 2022 12:01
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking quite good! Tested this with an active workspace, a multi-workspace and no workspace:

  • Using the New File command creates an untitled editor widget
  • Saving (Ctrl+S) it delegates to the SAVE_AS mechanism
  • Untitled files (from my test extension) are marked as dirty
  • Saving these also delegates to the SAVE_AS mechanism

I have some minor questions and comment though.

@colin-grant-work colin-grant-work force-pushed the feature/open-untitled-editor branch from a85cab3 to 9689bc4 Compare March 14, 2022 15:08
@colin-grant-work colin-grant-work force-pushed the feature/open-untitled-editor branch from 46d8a0b to 40aaca6 Compare March 15, 2022 19:18
@colin-grant-work colin-grant-work force-pushed the feature/open-untitled-editor branch from 40aaca6 to f64e087 Compare March 15, 2022 19:27
@colin-grant-work colin-grant-work requested a review from msujew March 21, 2022 18:21
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 👍

…feature/open-untitled-editor

Conflicts:
	CHANGELOG.md
	packages/plugin-ext/src/main/browser/documents-main.ts
	packages/plugin-ext/src/main/browser/editor/untitled-resource.ts
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that the behavior works well 👍

  • creating untitled documents works
  • creating multiple untitled documents
  • the untitled document is closeable without a prompt if not dirty
  • the untitled document produces a prompt if dirty using save
  • the untitled document produces a prompt if dirty and we close the editor
  • the save all command does not apply for untitled documents (similarly to vscode)
  • performing save all will properly save workspace documents, but not untitled documents
  • toggling the auto save does not apply for untitled documents (does not produce a save)

I looked at the code at a high level and it seems fine to me as well.

@vince-fugnitto vince-fugnitto added editor issues related to the editor core issues related to the core of the application labels Mar 29, 2022
@colin-grant-work colin-grant-work merged commit bd604c3 into eclipse-theia:master Apr 1, 2022
@colin-grant-work colin-grant-work deleted the feature/open-untitled-editor branch April 1, 2022 18:15
@vince-fugnitto vince-fugnitto added this to the 1.25.0 milestone Apr 28, 2022
perrinjerome added a commit to perrinjerome/theia-open that referenced this pull request May 7, 2022
Rely on untitled scheme from eclipse-theia/theia#10868
to create an editor for a file that will be saved as the path passed on
the command line.

The protocol was changed to use `uri` instead of `filePath`. The python
client was updated to keep compatibility with the new protocol, but the
feature of opening non existent files is only implemented in the nodejs
client.
perrinjerome added a commit to perrinjerome/theia-open that referenced this pull request May 7, 2022
Rely on untitled scheme from eclipse-theia/theia#10868
to create an editor for a file that will be saved as the path passed on
the command line.

The protocol was changed to use `uri` instead of `filePath`. The python
client was updated to keep compatibility with the new protocol, but the
feature of opening non existent files is only implemented in the nodejs
client.
perrinjerome added a commit to perrinjerome/theia-open that referenced this pull request May 7, 2022
Rely on untitled scheme from eclipse-theia/theia#10868
to create an editor for a file that will be saved as the path passed on
the command line.

The protocol was changed to use `uri` instead of `filePath`. The python
client was updated to keep compatibility with the new protocol, but the
feature of opening non existent files is only implemented in the nodejs
client.
@colin-grant-work
Copy link
Contributor Author

@Tesbarmix1, I'm not sure what you mean; could you clarify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core issues related to the core of the application editor issues related to the editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow creating new files without a workspace
3 participants