Re: [code] Small addition to snippets

From: Mitchell <m.att.foicica.com>
Date: Mon, 12 Nov 2018 11:21:07 -0500 (EST)

Hi Pedro,

On Mon, 12 Nov 2018, Pedro Andres Aranda Gutierrez wrote:

> Hi,
>
> maybe because I'm caĆ³tico, I sometimes quit a snippet prematurely. This
> blocks the editor with a message of the likes that ph is nil and can't be
> indexed in the message buffer.
>
> Here's a quick&dirty fix for it:
> +++ snippets.lua 2018-11-12 11:47:57.000000000 +0100
> --- snippets.lua.orig 2018-11-12 11:52:51.000000000 +0100
> @@ -551,14 +551,9 @@
> end
> local id = buffer:indicator_value_at(M.INDIC_PLACEHOLDER, s)
> local ph = snapshot.placeholders[id]
> + if not ph then
> + -- ui.print(string.format("snapshot.placeholders doesn't have %s as
> index", id))
> + return nil, nil
> + else
> + if (not index or ph.index == index) and (not type or ph[type]) then
> + return s, ph
> + end
> + end
> - if (not index or ph.index == index) and (not type or ph[type]) then
> - return s, ph
> - end
> s = buffer:indicator_end(M.INDIC_PLACEHOLDER, i)
> end
> end

Is it sufficient to make the `if` conditional `if ph and (not index or ph.index ...`? I wasn't able the trigger the problem on my own.

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 Mon 12 Nov 2018 - 11:21:07 EST

This archive was generated by hypermail 2.2.0 : Tue 13 Nov 2018 - 06:50:37 EST