Bug 270376

Summary: multiple space are eaten with irc rich text
Product: [Applications] konversation Reporter: Bernd Buschinski <b.buschinski>
Component: ircviewAssignee: argonel <argonel>
Status: RESOLVED FIXED    
Severity: normal CC: konversation-devel
Priority: NOR    
Version: Git   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Bernd Buschinski 2011-04-07 23:15:52 UTC
Version:           Git (using KDE 4.6.2) 
OS:                Linux

For the follwing examples I am going to ignore the rich text effect.

If you write text like
"test %C09 test"
it will be shown as
"test test"
with just one space.

The text is correctly generated and passed to KTextBrowser as
"test <font color="#00ff00"> test</font>"
(still 2 spaces)

This behavior seems to be known, as there is a "workaround" in
ircview.cpp line 1089
    // Replace a pair of spaces with "<space>&nbsp;" to preserve some semblance of text wrapping.
    filteredLine.replace("  ", " \xA0");

but "test %C09 test" is not pair of spaces, so it does not apply.

And as the comment says replacing all spaces does not work as it would break text wrapping.

NOTE: this happens with all irc richtext chars, bold, italic, underlined...
NOTE2: this also happens with konv 1.2.3

Reproducible: Always
Comment 1 Bernd Buschinski 2011-04-13 22:46:07 UTC
Git commit 2cd9e132b50584a78455a4a70460f6ea73331360 by Bernd Buschinski.
Committed on 13/04/2011 at 22:51.
Pushed by buschinski into branch 'master'.

Replace pairs of spaces with "<space>&nbsp;" to preserve some semblance of text wrapping
code:   filteredLine.replace("  ", " \xA0");
This used to work like above. But just for normal text like "test    test"
It got replaced as "test \xA0 \xA0test" and QTextEdit showed 4 spaces.
In case of color/italic/bold codes we don't necessary get a real pair of spaces
just "test<html> <html> <html> <html> test" and QTextEdit shows it as 1 space.
Now if we remember the last char, to ignore html tags, and check if current and last ones are spaces
we replace the current one with \xA0 (a forced space) and get
"test<html> <html>\xA0<html> <html>\xA0test", which QTextEdit correctly shows as 4 spaces.
BUG: 270376

M  +24   -2    src/viewer/ircview.cpp     

http://commits.kde.org/konversation/2cd9e132b50584a78455a4a70460f6ea73331360