replace_sel also causes weird scrolling?

From: David Tweed <david.tw....at.gmail.com>
Date: Fri, 6 May 2011 01:31:08 +0100

Hi,

I'm getting some "interesting" behaviour which might be at either the
GTKScintilla or textadept layer. With textadept 3.7 beta 3 I've added
some preliminary abbreviation expansion code. The end of the text
replacement routine in lua is

    if replacement then
      --massage replacement so case matches original
      if firstCharIsUpper then
          replacement=replacement:gsub("^%l", string.upper)
      end
      buffer:replace_sel(replacement)
    end
    --clear selection so next keypress doesn't zap it
    buffer:set_sel(cur_pos,cur_pos)
    buffer:goto_pos(cur_pos) -- ************

This works correctly semantically, but when I use it on a buffer with
wrapped lines (I'm primarily writing natural language text), at the
point where a replacement is triggered the screen seems to "implictly
scroll" so that the text cursor position is "scrolled down"
four-or-five of lines (and if the cursor is near the bottom of the
screen, this can even result in it moving off the screen). When I type
the next character the line snaps back to what looks like where it
originally was. The starred goto_pos isn't actually needed by the
code, but I put it in to see if it would avoid this effect, but it
doesn't.

I've scanned through the snippets lua code but it doesn't appear to do
anything special about this, but then I imagine that it wouldn't be an
issue with snippets since it looks like they're designed to be
multi-line (rather than single word insertions/replacements) where it
wouldn't matter if the display scrolls.

I just thought I'd ask if anyone else has encountered (and maybe
solved) this issue in the past?

-- 
cheers, dave tweed__________________________
computer vision reasearcher: david.tw....at.gmail.com
Received on Thu 05 May 2011 - 20:31:08 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:06:21 EST