mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-23 00:02:27 +00:00
fix(themes): stop the theme editor from failing without saying so
"Duplicate to edit" logged its failure and did nothing else — a button that does nothing is indistinguishable from having clicked the wrong thing. Worse, every colour edit runs through mutate_active_theme, which returned early on a write failure: the picker moved, the theme did not, and nothing said why. Both now report, through the same notify_err the rest of the app uses. On a themes folder the user cannot write, that reads "Could not duplicate the theme: You do not have permission." rather than "Permission denied (os error 13)", or nothing at all.
This commit is contained in:
+14
-1
@@ -1388,7 +1388,17 @@ impl Tty7App {
|
||||
crate::ui::presets::load_registry(cx);
|
||||
self.set_preset(&new_id, window, cx);
|
||||
}
|
||||
Err(e) => log::warn!("failed to duplicate theme: {e}"),
|
||||
// A button that does nothing is the worst kind of failure: there
|
||||
// is no way to tell it from "I clicked the wrong thing".
|
||||
Err(e) => {
|
||||
log::warn!("failed to duplicate theme: {e}");
|
||||
crate::ui::host_ops::HostOps::notify_err(
|
||||
window,
|
||||
cx,
|
||||
t(L10nKey::ThemeDuplicateFailed),
|
||||
&e,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1405,7 +1415,10 @@ impl Tty7App {
|
||||
}
|
||||
mutate(&mut theme);
|
||||
if let Err(e) = crate::ui::presets::write_theme_file(&theme) {
|
||||
// Every colour edit runs through here. Without this the picker
|
||||
// moves, the theme does not, and nothing says why.
|
||||
log::warn!("failed to write theme file: {e}");
|
||||
crate::ui::host_ops::HostOps::notify_err(window, cx, t(L10nKey::ThemeSaveFailed), &e);
|
||||
return;
|
||||
}
|
||||
crate::ui::presets::load_registry(cx);
|
||||
|
||||
@@ -134,6 +134,9 @@ pub fn translate_en(key: L10nKey) -> &'static str {
|
||||
}
|
||||
L10nKey::SettingsAnsiColors => "ANSI colors",
|
||||
L10nKey::SettingsCustomThemes => "Custom themes",
|
||||
L10nKey::ThemeDuplicateFailed => "Could not duplicate the theme",
|
||||
L10nKey::ThemeSaveFailed => "Could not save the theme",
|
||||
L10nKey::OpenInFileManagerFailed => "Could not open {path}",
|
||||
L10nKey::SettingsCustomThemesIntro => {
|
||||
"Duplicate a theme to edit its colors here, or drop your own in the themes folder: a tty7 YAML theme or an iTerm2 .itermcolors scheme."
|
||||
}
|
||||
|
||||
@@ -134,6 +134,9 @@ pub fn translate_ja(key: L10nKey) -> Option<&'static str> {
|
||||
L10nKey::SettingsBackgroundImageDesc => "背景色の上、テキストの下に表示されます",
|
||||
L10nKey::SettingsAnsiColors => "ANSI カラー",
|
||||
L10nKey::SettingsCustomThemes => "カスタムテーマ",
|
||||
L10nKey::ThemeDuplicateFailed => "テーマを複製できませんでした",
|
||||
L10nKey::ThemeSaveFailed => "テーマを保存できませんでした",
|
||||
L10nKey::OpenInFileManagerFailed => "{path} を開けませんでした",
|
||||
L10nKey::SettingsCustomThemesIntro => {
|
||||
"テーマを複製して色を編集するか、テーマフォルダに自作テーマ(tty7 の YAML テーマまたは iTerm2 の .itermcolors スキーム)を置けます"
|
||||
}
|
||||
|
||||
@@ -161,6 +161,9 @@ pub enum L10nKey {
|
||||
SettingsBackgroundImageDesc,
|
||||
SettingsAnsiColors,
|
||||
SettingsCustomThemes,
|
||||
ThemeDuplicateFailed,
|
||||
ThemeSaveFailed,
|
||||
OpenInFileManagerFailed,
|
||||
SettingsCustomThemesIntro,
|
||||
SettingsDuplicateToEdit,
|
||||
SettingsHosts,
|
||||
@@ -1202,6 +1205,9 @@ mod tests {
|
||||
L10nKey::SettingsBackgroundImageDesc,
|
||||
L10nKey::SettingsAnsiColors,
|
||||
L10nKey::SettingsCustomThemes,
|
||||
L10nKey::ThemeDuplicateFailed,
|
||||
L10nKey::ThemeSaveFailed,
|
||||
L10nKey::OpenInFileManagerFailed,
|
||||
L10nKey::SettingsCustomThemesIntro,
|
||||
L10nKey::SettingsDuplicateToEdit,
|
||||
L10nKey::SettingsHosts,
|
||||
|
||||
@@ -118,6 +118,9 @@ pub fn translate_zh(key: L10nKey) -> Option<&'static str> {
|
||||
L10nKey::SettingsBackgroundImageDesc => "叠加在背景色之上、文字之下。",
|
||||
L10nKey::SettingsAnsiColors => "ANSI 颜色",
|
||||
L10nKey::SettingsCustomThemes => "自定义主题",
|
||||
L10nKey::ThemeDuplicateFailed => "无法复制主题",
|
||||
L10nKey::ThemeSaveFailed => "无法保存主题",
|
||||
L10nKey::OpenInFileManagerFailed => "无法打开 {path}",
|
||||
L10nKey::SettingsCustomThemesIntro => {
|
||||
"复制一个主题后可在此编辑其颜色,或者把自定义主题放入主题文件夹:tty7 YAML 主题或 iTerm2 的 .itermcolors 方案。"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user