After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 598161 - Wrong offset for text selection on lines with TAB characters
Wrong offset for text selection on lines with TAB characters
Status: RESOLVED FIXED
Product: gnome-commander
Classification: Other
Component: internal-viewer
1.2.x
Other Linux
: Normal normal
: 1.2.9
Assigned To: Assaf Gordon
Assaf Gordon
Depends on:
Blocks:
 
 
Reported: 2009-10-12 14:19 UTC by Karel Klic
Modified: 2014-04-09 07:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Get text_mode_pixel_to_offset() to handle tab-characters correctly (1.54 KB, patch)
2012-05-02 18:12 UTC, Jan Vleeshouwers
none Details | Review

Description Karel Klic 2009-10-12 14:19:39 UTC
1. Create a file containing text with tabulator characters.
2. Open the file using internal viewer.
3. Choose a line where some text is preceded by tab characters.
4. Select the text on that line by mouse.

-- Only the text on the right side of the mouse cursor is selected.
-- I would expect that the text directly under the mouse cursor is selected.
Comment 1 Karel Klic 2009-10-12 14:22:28 UTC
It happens in version 1.2.8.2 in Fedora 11.
Also reproduced in development version 1.3.9 in Fedora Rawhide.
Comment 2 Vít Ondruch 2011-03-16 13:02:51 UTC
Unfortunately this bug is still not fixed in Fedora 15 :(
Comment 3 Jan Vleeshouwers 2012-05-02 16:02:23 UTC
The bug is still present in version 1.2.8.15. As a frequent user of gnome-commander, I thought I might as well see if I could do something about it.

The problem is in text_mode_pixel_to_offset() in text-renderer.cc, which considers every character to be equivalent to a column (line 1651).

A work-around is easy: alter the tab-size to 1 by modifying the settings file (in my Ubuntu-case: ~/.gnome2/gnome-commander).

The solution is not difficult either: the viewer should check each character on a line and count tab_size columns for a tab (instead of 1). The function gv_input_mode_get_utf8_char() gets the character at a specific offset, the rest is straight-forward.

I haven't found out yet how to file an update, but I'll check.
Comment 4 Jan Vleeshouwers 2012-05-02 18:12:08 UTC
Created attachment 213321 [details] [review]
Get text_mode_pixel_to_offset() to handle tab-characters correctly
Comment 5 Jan Vleeshouwers 2012-05-06 13:56:10 UTC
If you have scrolled the text to the right, a similar selection error occurs.
Although this is not related to TAB characters, I'll add the comment here since the solution is so simple. 
The function text_mode_pixel_to_offset() should also account for horizontal scrolling:

text-render.cc, line 1640:
-    column = x / obj->priv->char_width;
+    column = x / obj->priv->char_width + obj->priv->column;
Comment 6 Uwe Scholz 2014-04-09 07:58:51 UTC
Thank you for the applied patch. The bugfix will go into the next bugfix release of GCMD v1.4.2.