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 756707 - calculations of lineno and offset for external editor gvim component is broken
calculations of lineno and offset for external editor gvim component is broken
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: Composer
3.18.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: Tomas Popela
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2015-10-16 17:14 UTC by Reid Thompson
Modified: 2015-10-20 14:15 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Reid Thompson 2015-10-16 17:14:30 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.
Comment 1 Reid Thompson 2015-10-16 17:16:28 UTC
issue is currently present in 3.19.1, git master
Comment 2 Milan Crha 2015-10-19 10:24:18 UTC
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.
Comment 3 Tomas Popela 2015-10-20 14:15:17 UTC
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+