Files
helder/docs/guide/dialogs.md
T
2026-10-30 13:21:45 +01:00

164 lines
8.3 KiB
Markdown

# Dialogs
Helder asks you something in three ways: a confirm dialog before a risky action, a small name prompt for new and renamed entries, and the macOS unsaved-changes alert. This page shows each one, what it says, and which keys answer it.
[Guide index](index.md) · Related: [Right-click menu](right-click-menu.md), [Git](git.md), [Explorer](explorer.md), [File view](file-view.md), [Notifications](notifications.md)
## At a glance
```text
+----------------------------------------------------------------------------+
|//////////////////////////// dimmed window /////////////////////////////////|
|////////// +------------------------------------------------+ ////////////|
|////////// | (1) Discard changes to app/Http/User.php? | ////////////|
|////////// | | ////////////|
|////////// | (2) This reverts to the last commit and | ////////////|
|////////// | cannot be undone. | ////////////|
|////////// | | ////////////|
|////////// | (3)[ Cancel esc ] (4)[ Discard enter ] | ////////////|
|////////// +------------------------------------------------+ ////////////|
|////////////////////////////////////////////////////////////////////////////|
+----------------------------------------------------------------------------+
```
1. **Title**: the question, often with the path it is about.
2. **Body**: what will happen. Not every confirm dialog has one.
3. **Cancel**: closes the dialog and does nothing. Its key is `Esc`.
4. **Confirm button**: amber-deep, named after the action (Discard or Delete). Its key is `Enter`.
## Features
### Confirm dialog
The confirm dialog sits on top of a dimmed window. Nothing else takes keys while it is open.
- `Enter` or a click on the confirm button runs the action.
- `Esc`, a click on **Cancel**, or a click on the dimmed area outside cancels. Nothing changes.
Helder shows a confirm dialog for these actions:
| Action | Title | Body | Button | When |
|---|---|---|---|---|
| Discard (Git view) | `Discard changes to <path>?` | `This reverts to the last commit and cannot be undone.` | Discard | When `git.confirmDiscard` is on (default) |
| Delete (Git view, new files) | `Delete <path>?` | `New files are removed from disk. This cannot be undone.` | Delete | When `git.confirmDiscard` is on (default) |
| Delete file | `Delete file?` | `<path> will be permanently deleted.` | Delete | Always |
| Delete folder | `Delete folder?` | `<path>/ and everything inside it will be permanently deleted.` | Delete | Always |
#### Discard changes
Comes from **Discard** or **Delete** in the [Git](git.md) view, on a row or as **Discard all** / **Delete all** on a section. With more than one file, the title names the count instead of a path, for example `Discard changes to 3 files?`. When the files include a new file, the body says `New files are removed from disk. This cannot be undone.`
On confirm, a changed file loses its unstaged changes: it goes back to its staged version, or to the last commit when nothing is staged. A new file is deleted from disk. An open copy in the [File view](file-view.md) reloads.
**Restore** on a deleted file never asks. Stage and unstage never ask either.
#### Delete file or folder
Comes from **Delete file** or **Delete folder** in the [Explorer](explorer.md). It always asks. On confirm:
- The file, or the folder with everything inside it, is deleted for good. It does not go to the Trash.
- An open file that was deleted closes in the File view.
- A notification says `Deleted file` or `Deleted folder`, or `Delete failed`.
### Name prompt
The name prompt is a small panel for **New file**, **New folder**, **Rename file** and **Rename folder**. It opens where the right-click menu stood. The window is not dimmed.
```text
+------------------------------------------------+
| (1) [doc] New file (2)esc |
| +--------------------------------------------+ |
| | (3) file name... | |
| +--------------------------------------------+ |
| (4) creates [ app/Http/... ] |
| (5) enter create file esc cancel |
+------------------------------------------------+
```
1. **Title**: a file or folder icon in amber, and `New file`, `New folder`, `Rename file` or `Rename folder`.
2. **Esc chip**: a reminder that `Esc` closes the prompt.
3. **Name field**: has the keyboard as soon as the prompt opens. The hint reads `file name…` or `folder name…`.
4. **Preview**: the path that `Enter` will produce, in an amber chip. It reads `creates` for a new entry and `renames to` for a rename. It shows `…` while the name cannot be used.
5. **Footer**: the keys: `↵ create file`, `↵ create folder`, `↵ rename file` or `↵ rename folder`, and `esc cancel`.
How it works:
- Type a name. The preview follows each key.
- `Enter` creates or renames, then closes the prompt.
- `Esc`, or a click anywhere outside the panel, cancels.
- For a rename, the field starts with the current name. Only the part before the extension is selected, so typing a new name keeps `.php` or `.md`.
What happens after `Enter`:
- **New file**: the file is created empty and opens in the [File view](file-view.md). Its folders expand in the [Explorer](explorer.md).
- **New folder**: the folder is created and expands.
- **Rename**: the entry gets its new name. An open file stays open under the new name.
- A notification confirms: `Created file`, `Created folder`, `Renamed file` or `Renamed folder`, with the new path.
#### Names the prompt accepts
There are no error messages inside the prompt. Instead, `Enter` does nothing while the preview shows `…`. That happens when:
- The name is empty or only spaces.
- For a rename: the name has a `/`, is `.` or `..`, or is the same as the current name.
For **New file** and **New folder**, a name with slashes creates the folders on the way. `tests/Unit/MathTest.php` creates `tests/Unit/` when it does not exist yet. Leading and trailing slashes are dropped. Spaces around the name are trimmed.
A rename that only changes capitals (`readme.md` to `README.md`) works.
When a file or folder with that name already exists, nothing is overwritten. The prompt closes and a notification says `Create failed` or `Rename failed`, with the name.
### Unsaved changes
When the open file has unsaved edits and you are about to lose them, Helder shows the standard macOS alert:
```text
+------------------------------------------------------+
| (!) Save changes to UserController.php? |
| |
| app/Http/UserController.php has unsaved edits. |
| They are lost if you close without saving. |
| |
| [ Save ] [ Don't Save ] [ Cancel ] |
+------------------------------------------------------+
```
It appears when you:
- open another file, or the same file again, from any place;
- close the file with `Cmd+W`;
- close the window or switch to another project. Each file with unsaved edits asks in turn.
The buttons:
- **Save** writes the file, then goes ahead. When the save fails, the file stays open and nothing else happens.
- **Don't Save** drops the edits and goes ahead.
- **Cancel** keeps the file, its edits and the selection in the [Explorer](explorer.md). Nothing happens.
`Enter` picks **Save**, `Esc` picks **Cancel**, as in every macOS alert.
With `editor.autoSave` on, opening another file saves the open one silently, without this alert.
## Keyboard
| Keys | Action |
|---|---|
| `Enter` | Confirm dialog: run the action. Name prompt: create or rename. Unsaved alert: Save |
| `Esc` | Cancel any of the three |
## Settings
| Setting | Default | Effect |
|---|---|---|
| `git.confirmDiscard` | `true` | Ask before Discard and Delete in the Git view |
| `editor.autoSave` | `false` | Save the open file silently instead of asking, when you open another file |
## Related
- [Right-click menu](right-click-menu.md): where most of these dialogs start.
- [Git](git.md): discard and delete.
- [Explorer](explorer.md): new, rename and delete.
- [File view](file-view.md): saving, and the unsaved-edits dot.
- [Notifications](notifications.md): the message after each action.
- [Configuration](configuration.md): where the settings live.