From 09cf22133f61d1fb6eb416bf7081e5493e19242c Mon Sep 17 00:00:00 2001 From: koy Date: Thu, 19 Sep 2024 13:32:41 +0800 Subject: [PATCH] update: fix mismatch search content --- src/plugins/search/search.js | 4 ++-- test/e2e/search.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 487718bff..d4e33e3c3 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -230,8 +230,8 @@ export function search(query) { start = indexContent < 11 ? 0 : indexContent - 10; end = start === 0 ? 100 : indexContent + keyword.length + 90; - if (postContent && end > postContent.length) { - end = postContent.length; + if (handlePostContent && end > handlePostContent.length) { + end = handlePostContent.length; } const matchContent = diff --git a/test/e2e/search.test.js b/test/e2e/search.test.js index 8fc04adf6..0d0056ae2 100644 --- a/test/e2e/search.test.js +++ b/test/e2e/search.test.js @@ -254,7 +254,7 @@ console.log('Hello World'); await searchFieldElm.fill('searchHere'); // there is a newline after searchHere and the markdown part ```js ``` it should be removed expect(await resultsHeadingElm.textContent()).toContain( - "...searchHere\nconsole.log('Hello Worl...", + "...searchHere\nconsole.log('Hello World');...", ); });