Re: [code] [textadept] buffer:search_anchor()

From: Mitchell <m.att.foicica.com>
Date: Thu, 5 Feb 2015 08:54:12 -0500 (EST)

Hi Chris,

On Thu, 5 Feb 2015, Chris Emerson wrote:

> Hi,
>
> I was doing something along the lines of:
>
> buffer.current_pos = x
> buffer:search_anchor()
>
> buffer:search_next(...)
>
> but unexpectedly finding things early (ie before x).
>
> It turns out that when there's a selection, search_anchor() ends up setting
> the anchor to the start of the selection instead of buffer.current_pos.
>
> Is that expected? It doesn't seem to match my reading the Textadept API
> documentation.

I didn't expect this, no. I've always used `buffer:goto_pos(x)` and then
`buffer:search_anchor()`. I'll update the documentation. According to the
Scintilla docs:

SCI_SEARCHANCHOR sets the search start point used by SCI_SEARCHNEXT and
SCI_SEARCHPREV to the start of the current selection, that is, the end of
the selection that is nearer to the start of the document. You should
always call this before calling either of SCI_SEARCHNEXT or
SCI_SEARCHPREV.

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 05 Feb 2015 - 08:54:12 EST

This archive was generated by hypermail 2.2.0 : Fri 06 Feb 2015 - 06:26:49 EST