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

From: Robert Gieseke <>
Date: Sun, 26 Jan 2014 11:31:11 +0100

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?


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sun 26 Jan 2014 - 05:31:11 EST

This archive was generated by hypermail 2.2.0 : Sun 26 Jan 2014 - 06:32:32 EST