From 8d2e3bfd20d151f80377906f6858bd4e8293da8e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 2 Sep 2025 17:16:56 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/15737 --- app/src/protyle/toolbar/index.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 923e74c84..480a1fcc7 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -1273,23 +1273,25 @@ export class Toolbar { let html = ""; // sort let matchInput = false; - matchLanguages.sort((a, b) => { - if (a.startsWith(lowerCaseValue) && b.startsWith(lowerCaseValue)) { - if (a.length < b.length) { + if (lowerCaseValue) { + matchLanguages.sort((a, b) => { + if (a.startsWith(lowerCaseValue) && b.startsWith(lowerCaseValue)) { + if (a.length < b.length) { + return -1; + } else if (a.length === b.length) { + return 0; + } else { + return 1; + } + } else if (a.startsWith(lowerCaseValue)) { return -1; - } else if (a.length === b.length) { - return 0; - } else { + } else if (b.startsWith(lowerCaseValue)) { return 1; + } else { + return 0; } - } else if (a.startsWith(lowerCaseValue)) { - return -1; - } else if (b.startsWith(lowerCaseValue)) { - return 1; - } else { - return 0; - } - }); + }); + } const eventDetail = {languages: matchLanguages}; if (protyle.app && protyle.app.plugins) {