Mercurial > octave
changeset 22178:30a0756e6318
Go to right editor line number, even with folding (bug #47414)
* file-editor-tab.cc (center_current_line, handle_context_menu_edit):
Expand current line, if it is folded. Convert "document" line number
to "visible" line number before calling SCI_SETFIRSTVISIBLELINE.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Mon, 14 Mar 2016 21:57:01 +1100 |
parents | 6e9f5408c0db |
children | 603f0d752de2 |
files | libgui/src/m-editor/file-editor-tab.cc |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc Mon Jul 25 17:44:02 2016 -0400 +++ b/libgui/src/m-editor/file-editor-tab.cc Mon Mar 14 21:57:01 2016 +1100 @@ -314,7 +314,10 @@ if (pos_fct > -1) { // reg expr. found: it is an internal function _edit_area->setCursorPosition (line, pos_fct); - _edit_area->SendScintilla (2613, line); // SCI_SETFIRSTVISIBLELINE + _edit_area->SendScintilla (2232, line); // SCI_ENSUREVISIBLE + // SCI_VISIBLEFROMDOCLINE + int vis_line = _edit_area->SendScintilla(2220, line); + _edit_area->SendScintilla (2613, vis_line); // SCI_SETFIRSTVISIBLELINE return; } @@ -2474,13 +2477,20 @@ { int line, index; _edit_area->getCursorPosition (&line, &index); + // compensate for "folding": + // step 1: expand the current line, if it was folded + _edit_area->SendScintilla (2232, line); // SCI_ENSUREVISIBLE + + // step 2: map file line num to "visible" one // SCI_VISIBLEFROMDOCLINE + int vis_line = _edit_area->SendScintilla (2220, line); int first_line = _edit_area->firstVisibleLine (); - if (always || line == first_line || line > first_line + visible_lines - 2) + if (always || vis_line == first_line + || vis_line > first_line + visible_lines - 2) { - first_line = first_line + (line - first_line - (visible_lines-1)/2); - _edit_area->SendScintilla (2613,first_line); // SCI_SETFIRSTVISIBLELINE + first_line += (vis_line - first_line - (visible_lines - 1) / 2); + _edit_area->SendScintilla (2613, first_line); // SCI_SETFIRSTVISIBLELINE } } }