From 124b96d78caf862c357acc599b01a1a7873575ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartek=20G=C3=B3rny?= <bartek@gorny.edu.pl>
Date: Fri, 13 Oct 2006 19:42:02 +0000
Subject: [PATCH] fix - if the last found word was close to the end, the last
 part was not returned

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10709 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 bt5/erp5_dms/ExtensionTemplateItem/cutFound.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py b/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py
index 93c30f33d8..dcc2af8df5 100644
--- a/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py
+++ b/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py
@@ -45,7 +45,8 @@ def generateParts(context,text,sw,tags,trail,maxlines):
   sw=sw.translate(tr).strip().split()
   test=lambda w:w.translate(tr).strip().lower() in sw
   i=0
-  for aw in text:
+  length=len(text)
+  for counter,aw in enumerate(text):
     if i==maxlines:
       raise StopIteration
     if test(aw):
@@ -57,6 +58,10 @@ def generateParts(context,text,sw,tags,trail,maxlines):
         i+=1
         yield par
         par=Part(tags,trail)
+      if counter==length-1:
+        if par.has:
+          par.chain.reverse()
+          yield par # return the last marked part
 
 
 def cutFound(context,txt,sw,tags,trail,maxlines):
-- 
2.30.9