Re: Re: [code][textadept] Some questions about buffer.set_theme()

From: Mitchell <m.att.foicica.com>
Date: Wed, 21 Mar 2018 11:02:12 -0400 (EDT)

Hi,

On Tue, 20 Mar 2018, Keresztes Barna wrote:

> On 18/03/2018 16:46, Mitchell wrote:
>> At the end of your function you can put this:
>>
>>   if buffer.get_lexer then buffer:set_lexer(buffer:get_lexer()) end --
>> refresh
>>
>> It's a bit of hack, but that should immediately refresh the entire buffer's
>> styles.
>>
>> Cheers,
>> Mitchell
> ...but unfortunately it causes an infinite recursion (and stack overflow) -
> at least on 10.0 alpha1.

Okay, then you'll have to add a state variable outside your `events.LEXER_LOADED` handler. Something like:

   local running_handler = false
   events.connect(events.LEXER_LOADED, function(lexer)
     -- ...
     if not running_handler and buffer.get_lexer then
       running_handler = true
       buffer:set_lexer(buffer:get_lexer())
       running_handler = false
     end
   end)

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 Wed 21 Mar 2018 - 11:02:12 EDT

This archive was generated by hypermail 2.2.0 : Thu 22 Mar 2018 - 06:47:36 EDT