Re: [code] Feature request: snippet._insert should allow replacing the selection

From: Mitchell <>
Date: Tue, 18 Apr 2017 21:43:45 -0400 (EDT)


On Tue, 18 Apr 2017, cryo shock wrote:

> Hi guys,
> I think, when Mitch finds the time to solve the problem with selected_text
> and *appending* or *replacing*, then your problem will be solved Pedro.

Yes, I think I identified the issue and committed a fix[1]. Testing
Pedro's snippets from his original screenshot seems to work fine.

> I'd also like to remind what I experienced so far:
> Instead of replacing, a snippet with selected_text gets appended after the
> highlighted text
> - problem is not occuring for a whole line only; it also happens for single
> words

Okay, I think this has been fixed. It seems to only happen when the caret
position is at the end of a selection. If it is at the beginning of the
selection, I was not able to reproduce the problem.

> - there seems to be a difference in using %selected_text while
> -- pasting snippets directly after each other
> -- on the contrary to pasting a snippet, then writing some text, then
> pasting a snippet again

Do you have an example? Sorry, but I don't see one in the e-mail chain.

> - problem might also have to do with *placeholders*
> -- personally I think, there might be a problem with the jump from %1 to
> %0, or with %n while n>=1 in general
> --- I think that, because there seems to happen an unexpected jump, when
> you *delete* a placeholder, without jumping there by using *Tab*-key
> before. I.e.: although there is no more placeholder, TA jumps to the
> beginning of the document and deletes the first symbol.
> ---- To clearify: when creating a snippet with placeholders, you can not
> assume, that the user will always use those placeholders. That counts for
> me. Sometimes after pasting a snippet I just use arrow keys to go down a
> line and delete (most of the time) the %0 placeholder by using
> Backspace-key. Then an unexpected event happens: when I use Tab-key again
> to create a simple Tab break, the cursor jumps to the first line of the
> buffer and deletes the first symbol.
> For example, CTX starts its docs with
> \starttext
> When I do as described above, then the first line looks like this ( _ is
> the cursor position after using Tab):
> _starttext

Again, an example would help me identify the issue. Textadept uses
invisible markers for snippet boundaries and placeholders. If you are
backspacing in all sorts of places while a snippet is running, you are
probably asking for trouble, as I didn't envision that's how snippets are



You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Tue 18 Apr 2017 - 21:43:45 EDT

This archive was generated by hypermail 2.2.0 : Wed 19 Apr 2017 - 06:25:31 EDT