From 38e91b68cfbd805abd3739441bb7d5041dd1bd94 Mon Sep 17 00:00:00 2001 From: HaoRui Date: Wed, 22 Jul 2026 10:52:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(find-bar):=20=E6=94=AF=E6=8C=81=20Shift+Ent?= =?UTF-8?q?er=20=E5=9C=A8=E6=9F=A5=E6=89=BE=E6=A0=8F=E4=B8=AD=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E4=B8=8A=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 .onSubmit 替换为 .onKeyPress(.return),根据修饰键区分: Enter 触发 onFindNext(),Shift+Enter 触发 onFindPrevious(), 补齐查找栏内反向遍历匹配的快捷操作。 --- Sources/MarkdownReader/Views/FindReplaceBar.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/MarkdownReader/Views/FindReplaceBar.swift b/Sources/MarkdownReader/Views/FindReplaceBar.swift index d153456..a38dd54 100644 --- a/Sources/MarkdownReader/Views/FindReplaceBar.swift +++ b/Sources/MarkdownReader/Views/FindReplaceBar.swift @@ -88,8 +88,14 @@ struct FindReplaceBar: View { .stroke(viewModel.totalMatchCount == 0 && !viewModel.searchText.isEmpty ? themeColors.danger : themeColors.border, lineWidth: 1) ) .focused($isSearchFieldFocused) - .onSubmit { - onFindNext() + .onKeyPress(.return, phases: .down) { context in + // Enter = 下一个,Shift+Enter = 上一个 + if context.modifiers.contains(.shift) { + onFindPrevious() + } else { + onFindNext() + } + return .handled } if !viewModel.searchText.isEmpty {