GNOME Bugzilla – Bug 598161
Wrong offset for text selection on lines with TAB characters
Last modified: 2014-04-09 07:58:51 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.
It happens in version 1.2.8.2 in Fedora 11. Also reproduced in development version 1.3.9 in Fedora Rawhide.
Unfortunately this bug is still not fixed in Fedora 15 :(
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.
Created attachment 213321 [details] [review] Get text_mode_pixel_to_offset() to handle tab-characters correctly
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;
Thank you for the applied patch. The bugfix will go into the next bugfix release of GCMD v1.4.2.