Re: [code] [textadept] Styling changes

From: Mitchell <>
Date: Mon, 24 Nov 2014 12:50:37 -0500 (EST)

Hi Robert,

On Sat, 22 Nov 2014, Robert Gieseke wrote:

> Hi Mitchell,
> Am 20/11/14 um 21:29 schrieb Mitchell:
> [...]
>> Okay, thanks. I thought that revision might be what is causing it.
>> Some background: Scintilla keeps track of the last correctly styled
>> position via `buffer.end_styled`. When a character is added to a line,
>> Scintilla usually rolls back `buffer.end_styled` to the beginning of the
>> line typed on and then calls on the lexer to style from that point
>> forward.
>> Prior to the change you pointed to, Scintilla didn't perform any styling
>> at all if the current lexer had no grammar, thus keeping the value of
>> `buffer.end_styled` at 0 (and keeping any user-applied styles). However,
>> this kept telling the lexer to re-style everything starting from zero,
>> which seemed inefficient (hence the change). In order to set
>> `buffer.end_styled` and prevent the same text from being lexed again and
>> again, I simply style all of that text in the default style. The side
>> effect is what you're seeing: any existing styles are overwritten. The
>> question is: how and when are you applying your styles? Is it possible to
>> re-apply your styles at the right time? If not, perhaps it's worth
>> reverting the change.
> Thanks for the explanation, I can workaround the issue by always
> applying a (default) style if none is given in Textredux' `add_text`
> function[1].
> What happens in `list.lua` when adding new columns is basically this:
> keys.c4 = function()
> local buffer = buffer
> buffer:add_text('Test')
> buffer:add_text('\n')
> buffer:start_styling(0, 0xff)
> buffer:set_styling(20, 4)
> buffer.add_text('Test')
> buffer:start_styling(5, 0xff)
> buffer:set_styling(20, 4)
> buffer:add_text(' ')
> end
> The last line triggers the 'un-styling'. (For the list this would be
> adding unstyled padding to the list items.) I'm fine with my workaround
> but I'm not sure if similar unstyling could happen for example with a
> spell checker: an error is highlighted in a line, char is added at the
> end of the line, styling at the beginning would be removed.

A spell checker would use indicators to highlight errors, as those are not
affected by styling changes.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Mon 24 Nov 2014 - 12:50:37 EST

This archive was generated by hypermail 2.2.0 : Tue 25 Nov 2014 - 06:53:53 EST