aboutsummaryrefslogtreecommitdiff
path: root/mod/search
diff options
context:
space:
mode:
Diffstat (limited to 'mod/search')
-rw-r--r--mod/search/start.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/mod/search/start.php b/mod/search/start.php
index 314aa4710..19de06dd7 100644
--- a/mod/search/start.php
+++ b/mod/search/start.php
@@ -249,8 +249,12 @@ function search_get_highlighted_relevant_substrings($haystack, $needle, $min_mat
}
$string = substr($haystack, $offset, $limit - $offset);
- if ($limit-$offset < strlen($haystack)) {
- $string = "$string...";
+ if ($offset != 0) {
+ $string = "...$string";
+ }
+
+ if ($limit + $offset >= strlen($haystack)) {
+ $string .= '...';
}
$substrings[] = $string;