Bug 3070 - misbehaving text wrapping when URL chars are present
Summary: misbehaving text wrapping when URL chars are present
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail
Classification: Unclassified
Component: UI/Compose Window (show other bugs)
Version: 3.9.3
Hardware: PC Linux
: P3 minor
Assignee: users
URL: http://bugs.debian.org/736589
Depends on:
Blocks:
 
Reported: 2014-01-25 21:59 CET by Ricardo Mones
Modified: 2019-01-06 11:26 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo Mones 2014-01-25 21:59:07 CET
Quoting original submitter:

[...]
Anyway, in auto-wrap mode, if a word I'm typing begins with a `/' (for example,
/proc , /boot , /etc , etc), it will treat that word and the one before it as
one word, eg, ignore any spaces between them.  So if I write something like,
`Here's a few semi-imaginary filesystems in Linux: /proc /run /dev /sys', it
will treat the whole list as if it were one word, and I'll notice some goofy
text-wrapping behaviour if I go past the right margin.
[...]

Fully reproducible with the example provided by reporter, in a compose window type:

Here's a few semi-imaginary filesystems in Linux: /proc /run /dev /sys

Then you add another " /var" which causes it to wrap, the expected wrapping
would be:

Here's a few semi-imaginary filesystems in Linux: /proc /run /dev /sys
/var

But Claws Mail produces:

Here's a few semi-imaginary filesystems in
Linux: /proc /run /dev /sys /var

It also happens with ':' instead '/', for example, so my suspects goes to URL recognition code treating this as URLs and preventing normal wrapping.

Thanks in advance,
Comment 1 Andrej Kacian 2019-01-04 22:36:08 CET
This happens in function compose_get_line_break_pos(), because after pango_default_break() analyzes the line, the "is_line_break" flag for the '/' and ':' characters (possibly others too) is FALSE.

I have no idea why pango would not want to put '/' or ':' at the beginning of line. Following small, dirty hack makes line wrapping before a '/' work fine:

diff --git a/src/compose.c b/src/compose.c
index 8d8e097ba..4446d75a7 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -4259,7 +4259,7 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                gunichar wc;
                gint uri_len;
 
-               if (attr->is_line_break && can_break && was_white && !prev_dont_break)
+               if ((*p == '/' ||attr->is_line_break) && can_break && was_white && !prev_dont_break)
                        pos = i;
                
                was_white = attr->is_white;
@@ -4280,7 +4280,7 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                wc = g_utf8_get_char(p);
                if (g_unichar_iswide(wc)) {
                        col += 2;
-                       if (prev_dont_break && can_break && attr->is_line_break)
+                       if (prev_dont_break && can_break && (*p == '/' || attr->is_line_break))
                                pos = i;
                } else if (*p == '\t')
                        col += 8;
Comment 2 users 2019-01-06 11:26:05 CET
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2019-01-06 11:26:05.237644143 +0100
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=f4f722b814ad7ff6f3fa6cb5e83b330275784d97
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun Jan 6 11:23:19 2019 +0100

    Improve line breaks in compose window
    
    Fixes bug #3070: misbehaving text wrapping when URL chars are present