From 58fbf8812a093479c5a9d0d8770506f799fef0ea Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 16 Nov 2026 19:06:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20=E5=BF=AB=E6=8D=B7=E9=94=AE?= =?UTF-8?q?=E5=BD=95=E5=88=B6=E6=B5=8B=E8=AF=95=E6=8C=89=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=8C=91=E9=80=89=E6=9C=AA=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E7=BB=84=E5=90=88=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestKeymapAddRecordsTheChordPressedAfterIt 固定用 Ctrl+Alt+Shift+J 当作没有 动作占用的组合键。macOS 上成立,但 Linux 和 Windows 上它是“选择所有匹配” (editor.selectAllOccurrences)的默认快捷键,测试在前置检查就失败,main 的 Desktop CI 从 #2020 合入起在这两个平台一直是红的。 改为在 Ctrl+Alt+Shift 加字母里挑当前平台默认目录中第一个没被占用、可绑定的 组合键;三个平台上都会选到 A。测试本身的录制、写入和 Escape 断言不变。 --- .../internal/settingswindow/keymap_view_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/desktop/internal/settingswindow/keymap_view_test.go b/desktop/internal/settingswindow/keymap_view_test.go index d13d548c07..4803c62f40 100644 --- a/desktop/internal/settingswindow/keymap_view_test.go +++ b/desktop/internal/settingswindow/keymap_view_test.go @@ -10,12 +10,19 @@ import ( ) // unboundAction is the first action of the catalog without default keys, and a chord that no -// action holds by default, so a test can record one for the other. +// action holds by default, so a test can record one for the other. The defaults differ by +// platform (Control-Alt-Shift-J selects all occurrences outside macOS), so the chord is the +// first free Control-Alt-Shift letter of the running platform's catalog. func unboundAction(t *testing.T) (shortcuts.Action, keymap.Chord) { t.Helper() - chord := keymap.Chord{Modifiers: gfx.ModifierControl | gfx.ModifierAlt | gfx.ModifierShift, Char: 'j'} - if owner, taken := shortcuts.Overrides(nil).Owner(chord, ""); taken { - t.Fatalf("%s already holds %s", owner.ID, chord.Label()) + chord, found := keymap.Chord{}, false + for char := byte('a'); char <= 'z' && !found; char++ { + chord = keymap.Chord{Modifiers: gfx.ModifierControl | gfx.ModifierAlt | gfx.ModifierShift, Char: char} + _, taken := shortcuts.Overrides(nil).Owner(chord, "") + found = !taken && shortcuts.Bindable(chord) + } + if !found { + t.Fatal("every Control-Alt-Shift letter is held by a default shortcut") } for _, action := range shortcuts.All() { if len(shortcuts.Overrides(nil).Effective(action)) == 0 {