We've run into an unfortunate behavior or shorten_line.  When a commit
message starts with something like "This is in reference to
r123456\n------------------------------------------------",
shorten_line chops off the "r123456" in the revision log view.  This
is because when it is looking for word boundaries it searches for
spaces first and only searches for newlines if no spaces are found.
Here is a patch that will make it always find the last whitespace
character.  The code could be made a little bit shorter by just
returning the expression directly instead of dropping it in a
temporary variable, but I wasn't sure what the maintainers would
prefer.

This patch is in the public domain, or under the same license as Trac,
or assigned copyright to Edgewall, or whatever you want.

--David

Index: trac/util/text.py
===================================================================
--- trac/util/text.py   (revision 7509)
+++ trac/util/text.py   (working copy)
@@ -161,9 +161,7 @@
 def shorten_line(text, maxlen=75):
     if len(text or '') < maxlen:
         return text
-    shortline = text[:maxlen]
-    cut = shortline.rfind(' ') + 1 or shortline.rfind('\n') + 1 or
maxlen
-    shortline = text[:cut]+' ...'
+    shortline = text[:maxlen].rsplit(None, 1)[0]+' ...'
     return shortline

 def wrap(t, cols=75, initial_indent='', subsequent_indent='',

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to