mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-06-18 04:37:35 +02:00
Keep separators at start of the croped string
This commit is contained in:
parent
29c5f76d7f
commit
bd30ee97b8
@ -247,6 +247,15 @@ impl<'t> Matcher<'t, '_> {
|
||||
last_token_position += 1;
|
||||
}
|
||||
|
||||
// same for start
|
||||
while let Some(_separator_kind) = first_token_position
|
||||
.checked_sub(1)
|
||||
.and_then(|i| self.tokens.get(i))
|
||||
.and_then(|t| t.is_separator())
|
||||
{
|
||||
first_token_position -= 1;
|
||||
}
|
||||
|
||||
(first_token_position, last_token_position)
|
||||
}
|
||||
|
||||
@ -563,7 +572,7 @@ mod tests {
|
||||
// should crop the phrase instead of croping around the match.
|
||||
assert_eq!(
|
||||
&matcher.format(highlight, crop),
|
||||
"…Split The World is a book written by Emily Henry. …"
|
||||
"…. Split The World is a book written by Emily Henry. …"
|
||||
);
|
||||
|
||||
// Text containing some matches.
|
||||
|
Loading…
x
Reference in New Issue
Block a user