Skip to content

Commit

Permalink
fix(search-panel): prepend ellipsis to truncated text for better indi…
Browse files Browse the repository at this point in the history
…cation of content omission
  • Loading branch information
purocean committed Jan 6, 2025
1 parent a65c964 commit 4139774
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/renderer/components/SearchPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ function markText (text: string, ranges: ISearchRange[]) {
} else if (item.type === 'span') {
const lastSpanLength = item.value!.length
const keepChars = previousChars - (length - lastSpanLength)
item.value = item.value!.slice(-keepChars)
item.value = '...' + item.value!.slice(-keepChars)
contentLength -= lastSpanLength - keepChars
break
}
Expand All @@ -672,7 +672,9 @@ function markText (text: string, ranges: ISearchRange[]) {
const pushText = (type: Exclude<typeof result[number]['type'], 'br'>, text: string) => {
const value = (text.length + contentLength > maxPreviewLength)
? text.slice(0, maxPreviewLength - contentLength) + '...'
? (type === 'span' && !hasMarked)
? '...' + text.slice(-maxPreviewLength + contentLength)
: text.slice(0, maxPreviewLength - contentLength) + '...'
: text
result.push({ type, value })
contentLength += value.length
Expand Down

0 comments on commit 4139774

Please sign in to comment.