Re: [code] [code}[textadept] vertical scrolling bug?

From: Peter Rolf <indiego.att.gmx.net>
Date: Mon, 11 Dec 2017 01:21:46 +0100

Am 2017-12-10 um 17:20 schrieb Peter Rolf:
> Am 2017-12-10 um 16:36 schrieb Mitchell:
>> Hi Peter,
>>
>> On Fri, 8 Dec 2017, Peter Rolf wrote:
>>
>>> Hi,
>>>
>>> I had problems with wrong 'lexer' values in my Elastic Tabstops width
>>> cache. The lexer cache for 'text' was even flooded with entries, when I
>>> only had 'lua' files opened (no "Message Buffer" open at that time). I
>>> could limit the wrong entries by filtering out "Message Buffer" related
>>> modifications ('events.MODIFIED'). When I tried to do the same with
>>> 'events.UPDATE_UI' (vertically scrolling) the inner function wasn't
>>> called anymore.
>>>
>>> This means, that the message buffer is kind of 'active' while vertically
>>> scrolling. Any inner code that relies on the correct 'buffer' value
>>> while scrolling will fail.
>>>
>>> Here is the code to reproduce the problem. Just put it into an existing
>>> module or make a new one for testing.
>>>
>>> -----
>>> local UPDATE_V_SCROLL = buffer.UPDATE_V_SCROLL -- UPDATE_UI (4)
>>>
>>> local function buffer_problem(updated)
>>>  if updated and (updated & UPDATE_V_SCROLL > 0) and (not buffer._type
>>> == _L["[Message Buffer]"]) then
>>>    error("Never called...")
>>>  end
>>> end
>>>
>>> events.connect(events.UPDATE_UI, buffer_problem)
>>> ----
>>>
>>>
>>> Activate the code and use the vertical scrollbar in any buffer, that is
>>> not the "Message Buffer". Nothing will happen, no 'error' raised.
>>> Tested only with the nightly builds (sorry, already deleted
>>> 'properties.lua') on WIN32.
>>
>> I've been bit by this before.
>>
>>     not buffer._type == _L[...]
>>
>> should be
>>
>>     buffer._type ~= _L[...]
>>
>> or
>>
>>     not (buffer._type == _L[...])
>>
>> Cheers,
>> Mitchell
>
>
> Thanks for the pointer. So the bug hunt goes on. I wouldn't be
> surprised, if it is caused by one of my lua code 'optimizations' :D
>
>
> Cheers, Peter
>

For the records:

The cache is now working as intended. Actually one simple line fixes all
the problems.

local lexer = buffer:get_lexer()

-- If a file is opened, the added text causes numerous MODIFIED events;
-- don't waste any time in that case, as the lexer (and other buffer
-- related data) are not properly set yet.

if lexer == "text" and not buffer.filename then return 0 end

Best wishes, Peter

-- 
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 Sun 10 Dec 2017 - 19:21:46 EST

This archive was generated by hypermail 2.2.0 : Mon 11 Dec 2017 - 06:26:55 EST