From 049b72a8202588ce93e34c0ce91969446e8e88d1 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sat, 14 Sep 2024 14:23:56 +0800 Subject: [PATCH] change: FindTexts WithMatchOne option, found one, skip searching and return --- hrp/pkg/uixt/ai.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hrp/pkg/uixt/ai.go b/hrp/pkg/uixt/ai.go index 25487ef6..14898f99 100644 --- a/hrp/pkg/uixt/ai.go +++ b/hrp/pkg/uixt/ai.go @@ -167,16 +167,16 @@ func (t OCRTexts) FindTexts(texts []string, options ...ActionOption) (results OC continue } results = append(results, ocrText) + + // found one, skip searching and return + if actionOptions.MatchOne { + return results, nil + } } if len(results) == len(texts) { return results, nil } - - if actionOptions.MatchOne && len(results) > 0 { - return results, nil - } - return nil, errors.Wrap(code.CVResultNotFoundError, fmt.Sprintf("texts %s not found in %v", texts, t.texts())) }