ElyTable: a text file's default encoding follows the app's language (T-15)
This commit is contained in:
4 files changed
+33
-2
No files matched your search
@@ -469,3 +469,32 @@ fn a_whole_column_print_area_still_applies() {
|
||||
let layout = read(&mut cx, &book, sheet::print_layout, sheet::LAYOUT);
|
||||
assert!(layout.landscape, "applied with {shown}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_default_encoding_follows_the_apps_language() {
|
||||
use ely_gpui_component::i18n::I18n;
|
||||
use ely_lok::sheet::csv::Encoding;
|
||||
let dir = tempfile::tempdir().expect("a temp dir");
|
||||
let mut cx = TestAppContext::single();
|
||||
let Some((_window, book)) = book(&mut cx, dir.path()) else {
|
||||
eprintln!("SKIP: no LOK build");
|
||||
return;
|
||||
};
|
||||
let path = dir.path().join("gb.csv");
|
||||
// 你好 in GB18030: not UTF-8.
|
||||
std::fs::write(&path, [0xC4, 0xE3, 0xBA, 0xC3, b'\n']).expect("writes");
|
||||
for (tag, expected) in [("zh-CN", Encoding::Gb18030), ("en-US", Encoding::Windows1252)] {
|
||||
cx.update(|app| I18n::set_locale(tag, app));
|
||||
update(&mut cx, &book, |book, cx| book.ask_import(path.clone(), cx));
|
||||
asked(&cx, &book, |dialog| matches!(dialog, Dialog::Import(_)));
|
||||
let found = cx.update(|app| match book.read(app).dialog.as_ref() {
|
||||
Some(Dialog::Import(pending)) => pending.how.encoding,
|
||||
_ => unreachable!("an import dialog"),
|
||||
});
|
||||
assert_eq!(found, expected, "{tag}");
|
||||
update(&mut cx, &book, |book, cx| {
|
||||
book.dialog = None;
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,8 @@ impl Book {
|
||||
|
||||
pub(crate) fn ask_import(&mut self, path: PathBuf, cx: &mut Context<Self>) {
|
||||
let reading = path.clone();
|
||||
let chinese = ely_ui::i18n::resolve(&ely_platform::locale::system()) == "zh-CN";
|
||||
// The language the app shows, not the system's.
|
||||
let chinese = cx.global::<ely_gpui_component::i18n::I18n>().locale().tag == "zh-CN";
|
||||
cx.spawn(async move |this, cx| {
|
||||
// Guessing checks the whole file: off the window thread.
|
||||
let pending = cx
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
- [x] T-12 打印区域是整列或整行时页面设置无法应用 — 打印区域可为整列、整行(每端至多一个 $);R2 PASS
|
||||
- [x] T-13 打印失败报成“导出失败”(非 macOS 必现) — print_later 自己以“打印失败”报错,五个应用同;R1 PASS
|
||||
- [x] T-14 导入扫描把整个文件的每个字段都建成字符串 — split 逐行给出,扫描只留预览行与列标记;R1 PASS
|
||||
- [ ] T-15 非 UTF-8 文本的默认编码跟系统区域而不是界面语言
|
||||
- [x] T-15 非 UTF-8 文本的默认编码跟系统区域而不是界面语言 — 默认编码按应用所显示的语言;R1 PASS
|
||||
- [x] S-01 切换幻灯片后主画布不重画 — 已由 be31260(R2.4)修好并有单测,此处补勾
|
||||
- [x] S-02 `deck.rs` 超过 500 行 — 随 S-03 把 Extra 移到 extra.rs,deck.rs 463 行
|
||||
- [x] S-03 ElyShow 的缩放一两帧后弹回“适合幻灯片”,缩放功能不可用 — 只在标签首次观察时适合一次;R1 PASS
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
PASS
|
||||
Reference in new issue
Block a user