Include the whole word when displaying search results

This commit is contained in:
Veronica Berglyd Olsen
2024-06-16 15:58:30 +02:00
parent ee46fdb5b1
commit 611a6bb80a
2 changed files with 7 additions and 4 deletions
+3 -1
View File
@@ -348,7 +348,9 @@ class DocSearch:
rxMatch = rxItt.next()
pos = rxMatch.capturedStart()
num = rxMatch.capturedLength()
context = text[pos:pos+100].partition("\n")[0]
lim = text[:pos].rfind("\n") + 1
cut = text[lim:pos].rfind(" ") + lim + 1
context = text[cut:cut+100].partition("\n")[0]
if context:
results.append((pos, num, context))
count += 1