GNOME Bugzilla – Bug 756707
calculations of lineno and offset for external editor gvim component is broken
Last modified: 2015-10-20 14:15:17 UTC
the generated editor_cmd string is created with invalid values for the "+call cursor()" portion. 1) it appears that using offset in the editor_cmd is invalid. It will always calculate to zero. it is initialized to -1 it is incremented once 2) it appears that get_caret_position(view) is supposed to return the count of characters between start of text and caret/cursor position. It isn't, as best as i can determine, it is returning the count of characters between the start of the line that that caret/cursor is on and the caret/cursor. That value is passed to numlines() as pos. pos is supposed to be the count of chars between the start of the text and the caret/cursor position, which will be used as an iterator control to determine the number of lines between start of text and position.
issue is currently present in 3.19.1, git master
Thanks for a bug report. You are right with both 1) and 2). The 'offset' is supposed to be 'position', while the 'position' is supposed to be something completely different (that what you wrote at 2)). I'm moving this co composer, because it is presented wince the rewrite to the WebKitGTK+ composer, even the change will be in the External Editor plugin code. Tomas, could you look on it, please? It doesn't seem to be complicated, definitely for someone being familiar with the WebKitGTK+ API.
Fixed with following commits: Bug 756707 - calculations of lineno and offset for external editor gvim component is broken Fix get_caret_position to correctly return number of bytes from the beginning of the body to the current caret position and introduce the get_caret_offset function to return the number of bytes from the beginning of current line to the current caret position. Also the code of the numlines function was adjusted as the webkit_dom_range_to_string (used by both previously mentioned functions) is returning a text without new line characters, thus when counting the line number we cannot increase the counter if we hit a new line character. commit f41e8f8522cf3490e2a531f1ed46635d5c6c3ddb in the master branch for Evolution 3.19.1+ commit b8353ac769fea0abadd8038545e28bb33466ab8a in the gnome-3-18 branch for Evolution 3.18.2+