zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
39.53k stars 2.06k forks source link

Read-only buffers #5105

Open JosephTLyons opened 1 year ago

JosephTLyons commented 1 year ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Zed should open certain content with read-only buffers, such as Zed's log file and the telemetry file. Not sure how, but we should also not consider those buffers to be new files with changes, so that when we close them, we don't have to dismiss the modal asking us if we want to save or not.

Expected behavior

-

Environment

Zed 0.66.0 – /Applications/Zed Preview.app macOS 13.0.1 architecture arm64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue

No response

JosephTLyons commented 1 year ago

Maybe it's better to not make them read-only, in the random case a user wants to edit the contents of these files and save them for their own personal use. The main issue is that the initial state of the file is considered dirty, which is correct, but maybe we can have some sort of boolean when creating these things that lets us tell zed not to consider the initial state dirty so we aren't asked to save it when closing it. Not sure which way is the correct way.

Moshyfawn commented 3 months ago

There's another fair use case around read-only buffers described in #9218, which may be the catalyst to look into this further.

failable commented 3 months ago

View mode in Emacs: https://www.gnu.org/software/emacs/manual/html_node/emacs/View-Mode.html

15.6 View Mode
View mode is a minor mode that lets you scan a buffer by sequential screenfuls. It provides commands for scrolling through the buffer conveniently but not for changing it. Apart from the usual Emacs cursor motion commands, you can type SPC to scroll forward one windowful, S-SPC or DEL to scroll backward, and s to start an incremental search.

Typing q (View-quit) disables View mode, and switches back to the buffer and position before View mode was enabled. Typing e (View-exit) disables View mode, keeping the current buffer and position.

M-x view-buffer prompts for an existing Emacs buffer, switches to it, and enables View mode. M-x view-file prompts for a file and visits it with View mode enabled.