Lock the scene template against accidental edits
_template.md is a reference writers copy from by hand, not something the app reads programmatically, so an accidental edit to it is easy to make and easy to miss. The editor now shows it read-only with a lock banner; an "Unlock" button allows editing for the rest of the session, resetting back to locked the next time a file is selected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,32 @@ use super::*;
|
||||
|
||||
impl App {
|
||||
pub(super) fn editor(&mut self, ui: &mut egui::Ui) {
|
||||
// The bundled scene template is a reference writers copy from by
|
||||
// hand, not something the app reads — so an edit to it just sits
|
||||
// there, invisible, until someone notices the scene they copied from
|
||||
// it looks wrong. Lock it against typing until explicitly unlocked.
|
||||
let is_template = self
|
||||
.selected
|
||||
.and_then(|i| self.files.get(i))
|
||||
.is_some_and(|f| workspace::is_template_file(f));
|
||||
let locked = is_template && !self.template_unlocked;
|
||||
if is_template {
|
||||
ui.horizontal(|ui| {
|
||||
if locked {
|
||||
ui.label("🔒 This is the scene template — locked to prevent accidental edits.");
|
||||
if ui.button("Unlock").clicked() {
|
||||
self.template_unlocked = true;
|
||||
}
|
||||
} else {
|
||||
ui.label("🔓 Unlocked for editing.");
|
||||
if ui.button("Lock").clicked() {
|
||||
self.template_unlocked = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
|
||||
// Base monospace size scaled by the zoom percentage. `desired_width` stays
|
||||
// infinite and the scroll area is vertical-only, so text wraps to the pane
|
||||
// width at any zoom (no horizontal scrolling).
|
||||
@@ -113,6 +139,7 @@ impl App {
|
||||
.desired_width(f32::INFINITY)
|
||||
.desired_rows(rows)
|
||||
.layouter(&mut layouter)
|
||||
.interactive(!locked)
|
||||
.show(ui);
|
||||
if output.response.changed() {
|
||||
self.dirty = true;
|
||||
|
||||
Reference in New Issue
Block a user