edit: `Close Editor` exits the application if there are no other buffers to close.

  • open edit
  • select File then Close Editor
  • select File and Close Editor again

On launch:

Image

After closing the editor:

Image

Close Editor should give a warning only. Exit should terminate the application.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26 (15 by maintainers)

Commits related to this issue

Most upvoted comments

You know what, I’ll just remove this behavior now to be in line with VS Code. It doesn’t close on Ctrl+W, so… eh.

I would Ctrl-W without an open document very much to close edit. Why?

  1. Win-11 Notepad with one open document closes on Ctrl-W.
  2. Currently, I now have to use Ctrl-Q which Notepad ignores, and VS Code uses differently (https://stackoverflow.com/q/69663993)
  3. In a Developer Terminal inside VS 2022, Ctrl-Q is captured by VS (yes, I use VS Code-like key bindings in VS 2022).

So in summary, you chose a shortcut for closing edit that is different from what at least one other of your own editors uses (so in edit, I cannot use what I know from elsewhere), that is completely ignored by at least two of your own editors (so elsewhere, I cannot use what I re-learn in edit), and that is masked by a third of your own editors (so at times I cannot use anything at all).

I noticed this change almost immediately after upgrading (it has wrecked my muscle memory for writing git commit messages on the command line). I totally get the intended behavior if you just flat out launch edit, but perhaps this behavior could be dependent on either a global user preference or based on whether a filename was specified on the command line or not.

empty state with no open documents + open a directory + fuzzy file finder

Gotcha, interesting (and relevant to our prior discussion about extension paradigm and small vs. large programs).

(…) This simplifies discussions.

Yeah, nice. I only wish the prior art wasn’t a GUI application as that subtly influences the overall assumptions about interaction.

stupidly simple first, useful second, and powerful third. (…) If there are ever soft lines we can’t decide on, we’ll decide them according to gut feeling.

👌

I think Ctrl-W should close the program when it closes the last buffer, not with an additional keystroke afterwards.

This doesn’t matter much yet, but long-term I think it’s useful to have an empty state with no open documents. For instance, a feature where you can open a directory instead of a file. It then presents you with a fuzzy file finder. Example: nginx configuration file consist of a set of files all within /etc/nginx. It would be useful to be able to open /etc/nginx itself.

I don’t know that I should supply any further rationale for this. Both preferences are valid.

Yep, same. Hence me going back and forth on this. For now, I’ll imitate VS Code, not because it’s perfect, but rather because it lets me point to it and say, “it does it so we can do it too”. This simplifies discussions. If we ever decide otherwise, change defaults, and people complain, I’m 100% fine to take the heat. I’ve seen with other projects what happens if you give into community dissatisfaction over moving the cheese, and it’s routinely a bad decision. Moving the cheese is sometimes a good thing for long-term happiness. (Don’t give me a Windows as a counterpoint to this. There are obvious counterexamples, I know that. 😄)

Is Edit first and foremost supposed to be a CLI editor and fit into those established norms and paradigms, or is it supposed to be an “I can’t believe it’s not a GUI editor” bringing established GUI paradigms to the CLI?

This dichotomy will likely come up again and again and I’m undecided on this. The priority is to make this stupidly simple first, useful second, and powerful third. So, if we can have “I can’t believe it’s not a GUI editor!” without impacting the first two priorities, I’d do it. If there are ever soft lines we can’t decide on, we’ll decide them according to gut feeling.

Is there a reason it’s called Close Editor and not Close File to be consistent with the other file operations?

I assume this is an artefact of modeling Edit after VS Code, where:

  1. An Editor does not always have a specific file associated with it (e.g. an untitled document, a diff, an extension-provided view);
  2. A single file may be open in multiple Editor Groups (e.g. side by side), in which case only closing the last Editor actually results in closing the file.

Not sure how much of this will ever apply to Edit, but at least the untitled situation already exists.


VS Code hooks Ctrl+Q by default.

It also hooks Ctrl+W, no? For me that closes the focused terminal.


Why should you run edit within vscode?

To debug Edit while working on it in VS Code 😉

Not entirely sure if we should add it just yet. As GitMensch noted, anything we add will be something people come to rely on. This applies to Ctrl+W as much as the “Close All Editors” menu item.

That said, I do think we should add it eventually. It’s just that I would put it exclusively into the command palette. I would accept a PR though that adds support for key chord sequences, so that we can add support for Ctrl+K, Ctrl+W eventually - the same keybinding that VS Code uses for this.

We decided that we’d like to keep the current behavior. It also matches the behavior of most (all?) browsers which also close when you close the last tab. Of course, and editor is not a browser, but there’s small, tangible benefits to the current behavior and we should wait a bit longer to see whether it’s a problem for more people.

I copied the string from VS Code. I didn’t give it too big of a thought, but I did wonder about it as well. We can rename it to “Close File” later. (If we made that change now it would conflict with several other PRs.)

Is there a reason it’s called Close Editor and not Close File to be consistent with the other file operations? I know some apps like web browsers will close the program when doing a Ctrl-W on the last tab or an empty window so there is some precedent for not disabling the menu option when no documents are open.

because sometimes you press too long or double CTRL+W and don’t want your program to be closed - because if you want that you go with CTRL+Q directly (I obviously also care much more about the ASCII fallback for search [before you ask 😉 I don’t plan to work on “edit” myself, currently])