Goal: Add a small buffer list so Cortex can open, create, and switch between multiple files in one session.
Context: Splits and tabs are much more useful once the editor has real buffers underneath them.
The current editor has one active buffer and a directory picker at startup or /open time.
Cortex can already open a missing path as an empty buffer from the CLI or /open, but C-x C-f only exposes a picker of existing files.
Emacs-style find-file must also accept a filename that does not exist yet and create it when the buffer is saved.
This issue should introduce the buffer model without changing the app into a project explorer.
Proposed approach:
- Add an editor-level buffer list with one active buffer id or index.
- Preserve per-buffer dirty state and file path.
- Add Emacs-style
find-file behavior through C-x C-f.
- Let the find-file prompt accept an editable path, including a filename that does not exist.
- Open a missing path as an empty buffer associated with that path; create the file only when the buffer is saved.
- Keep the existing rule that saving does not create missing parent directories.
- Add
switch-buffer behavior for choosing an already-open buffer.
- Reuse the minibuffer or existing picker where practical.
- Keep each buffer's view state either in the buffer entry or a small associated view map, with splits in mind.
- Preserve current startup behavior for opening a file or directory.
Acceptance criteria:
- Opening a second file keeps the first buffer in memory.
- Switching buffers changes the visible file without losing unsaved edits.
- Dirty state is tracked per buffer.
- Saving saves the active buffer only.
- Quit warns if any open buffer is dirty, or has a clear scoped behavior documented in the issue plan.
C-x C-f opens an editable find-file prompt that accepts a file path.
- Entering an existing file path opens that file.
- Entering a missing file path opens an empty buffer associated with that exact path.
- Saving that buffer creates the file when its parent directory exists.
- Saving reports a clear error and keeps the buffer open when the parent directory does not exist.
- Canceling find-file leaves the active buffer unchanged.
C-x b switches between open buffers.
- Existing directory browsing and single-file editing behavior still works.
Verification:
- Run
cargo test.
- Manually open two existing files, edit both, switch between them, save one, save the other, and quit.
- Manually use
C-x C-f to enter a missing filename, add text, save it, and confirm the file was created with the expected contents.
- Manually use
C-x C-f with a path whose parent directory is missing and confirm save reports a clear error without losing the buffer.
- Manually cancel find-file and confirm the active buffer is unchanged.
- Manually confirm dirty quit behavior with one dirty inactive buffer.
- Manually confirm terminal cleanup after exit.
Out of scope:
- Splits and tabs.
- Project tree/sidebar.
- Recursive fuzzy file search.
- Recent files.
- Creating missing parent directories.
- External file reload.
Goal: Add a small buffer list so Cortex can open, create, and switch between multiple files in one session.
Context: Splits and tabs are much more useful once the editor has real buffers underneath them.
The current editor has one active buffer and a directory picker at startup or
/opentime.Cortex can already open a missing path as an empty buffer from the CLI or
/open, butC-x C-fonly exposes a picker of existing files.Emacs-style find-file must also accept a filename that does not exist yet and create it when the buffer is saved.
This issue should introduce the buffer model without changing the app into a project explorer.
Proposed approach:
find-filebehavior throughC-x C-f.switch-bufferbehavior for choosing an already-open buffer.Acceptance criteria:
C-x C-fopens an editable find-file prompt that accepts a file path.C-x bswitches between open buffers.Verification:
cargo test.C-x C-fto enter a missing filename, add text, save it, and confirm the file was created with the expected contents.C-x C-fwith a path whose parent directory is missing and confirm save reports a clear error without losing the buffer.Out of scope: