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

From: Mitchell <m.att.foicica.com>
Date: Tue, 28 Jan 2014 13:47:34 -0500 (Eastern Standard Time)

Hi Robert,

On Sun, 26 Jan 2014, Robert Gieseke wrote:

> Hi Mitchell,
>
> Am 1/9/14, 8:38 PM, schrieb Robert Gieseke:
>> Am 1/9/14, 6:39 PM, schrieb Mitchell:
>>> 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?
>>>
>>
>> I have word_wrap enabled so I hadn't thought of long lines, where it
>> obviously makes sense to scroll to. Maybe it's the buffer_after_switch
>> event, I have one vertical split, so after restoring all views it's
>> switching back again to the first view?
>> Every time I think I have a reproducible example it's not …
>
> I think I found a reproducible example:
> In a "clean" userhome I have only
> buffer.wrap_mode = buffer.WRAP_WORD
> in properties.lua.
>
> Opening textadept.c, centering for example l.100, and switching buffers
> lets wander this line to the top.
> If I add as you suggested
> buffer:scroll_range(buffer._anchor, buffer._current_pos)
> in core/ui.lua on l.347 the line is kept visible at the top of the view.
>
> Maybe using and restoring first_visible_line could be a fix for this?

Thanks for the follow up. I've looked into this more and identified the
problem. ui.lua:331 needs to have:

   buffer:doc_line_from_visible(buffer.first_visible_line)

instead of just

   buffer.first_visible_line

No other changes were necessary. This will be fixed in the next release.

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 Tue 28 Jan 2014 - 13:47:34 EST

This archive was generated by hypermail 2.2.0 : Wed 29 Jan 2014 - 06:39:59 EST