Re: [code] [textadept] Scroll position in session loading and buffer switching

From: Mitchell <m.att.foicica.com>
Date: Thu, 9 Jan 2014 12:39:30 -0500 (Eastern Standard Time)

On Wed, 8 Jan 2014, Robert Gieseke wrote:

> Hi,
>
> when reloading files from a session file the caret is often scrolled out
> of view (I think) because buffer:set_sel does some scrolling as well to
> ensure the selection is viewable. Maybe using 'current_pos' and 'anchor'
> directly could be an alternative, as they don't scroll into view if I
> understand the Scintilla docs correctly?
>
> -- session.lua, l.73
> buffer:line_scroll(0, buffer:visible_from_doc_line(first_visible_line))
> -- buffer:set_sel(anchor, current_pos)
> buffer.current_pos = current_pos
> buffer.anchor = anchor

When you say the caret is scrolled out of view, what do you mean? Is it
above or below the visible lines? Or is it off to the side on a long line?

In the cases where the selection is on part of a long line not visible in
the view, `buffer:set_sel()` ensures visibility. Setting `anchor` and
`current_pos` would definately leave the caret out of view in these cases
-- we do not want that to happen.

I'm not convinced that `buffer:set_sel()` is to blame for your
observations. I have done some brief tests on my machine but have yet to
reproduce what you describe. What happens when you add
`buffer:scroll_range(anchor, caret)` after line scrolling and selection
setting?

> The same seems to occasionally happen when switching buffers (from
> core/ui.lua, l. 337, the buffer_after_switch event). I don't have a
> reproducible constellation but quite often I have to press Ctrl-L
> (buffer.vertical_centre_caret) to refocus.
>
> Are they any disadvantages to using those instead of using 'set_sel'?

Just what I described earlier -- long lines.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 09 Jan 2014 - 12:39:30 EST

This archive was generated by hypermail 2.2.0 : Fri 10 Jan 2014 - 06:27:59 EST