Re: [textadept] Folding, lexer.lua

From: Tymur Gubayev <tymur.guba....at.gmail.com>
Date: Mon, 28 Nov 2011 23:11:26 +0100

Yes, I thought nested folding in multi-line comments is bad, so my
patch prevent it completely.
Your patch folds lines 2-3 here:

--[=[
        -- bug or feature?
        --
]=]

and my doesn't. I'm not sure which behaviour is better.
And i would avoid use of string.sub if not necessary, maybe smthng like this:
- if s > 1 and not line:sub(1, s - 1):find('^%s+$') then return 0 end
+ if s > 1 and line:match('^%s*()') < s then return 0 end

I will make a small article on wiki later this week (if nothing
prevents me by that...)

Tymur

On 28 November 2011 19:49, mitchell <c....at.caladbolg.net> wrote:
> Tymur,
>
> On Mon, 28 Nov 2011, Tymur Gubayev wrote:
>
>> Hi Mitchell,
>>
>> no, i'm using 4.2, and the bug is still there.
>> I made 2 screenshots to illustrate it, compare lines 3 and 8. There is
>> also another bug visible, not yet fixed, at line 21 - there is no
>> decrease in fold level, thus foldblock of the function at line 19 is
>> too large.
>> Test file also attached.
>
> Thank you, I have confirmed the bug for line comments. Instead of applying
> your patch, I have tested with this one:
>
> @@ -1298,6 +1298,7 @@
>  function fold_line_comments(prefix)
>   return function(text, pos, line, s)
>     if GetProperty('fold.line.comments', 0) == 0 then return 0 end
> +    if s > 1 and not line:sub(1, s - 1):find('^%s+$') then return 0 end
>     local prev_line_comment = prev_line_is_comment(prefix, text, pos, line,
> s)
>     local next_line_comment = next_line_is_comment(prefix, text, pos, line,
> s)
>     if not prev_line_comment and next_line_comment then return 1 end
>
> Please let me know if that fixes the issue for you. I actually do not have a
> set-up for your fold configuration so I cannot test the tic marks and such.
> (This would be a great idea for a wiki page article under the "Theming"
> section for users that want to have your folding marker set-up.)
>
> As for the bug in multi-line comments, your patch seems to stop the folding
> of nested comments in Lua. Is this intentional? Sorry if I'm missing
> something. I appreciate your contributions very much.
>
> mitchell
>
>>
>> Tymur
>>
>> On 28 November 2011 05:22, mitchell <c....at.caladbolg.net> wrote:
>>>
>>> Hi Tymur,
>>>
>>> On Sun, 27 Nov 2011, Tymur Gubayev wrote:
>>>
>>>> After long break I got my hands on textadept again... After I did find
>>>> the functions `buffer:marker_enable_highlight` and
>>>> `buffer:marker_set_back_selected` there was no need to reimplement the
>>>> wheel (highlight.indentation.guides), so I decided to move on to fix a
>>>> bug in folding comments, that annoyed my all the time.
>>>>
>>>> The bug:
>>>> In lua code like this:
>>>>
>>>> ----
>>>> -- 2nd line of the comment, so we will get a fold here
>>>>
>>>> fold level will increased twice but decreased only once; same is with
>>>> long comments.
>>>>
>>>> The easy and dirty solution I used is to check the style of symbol
>>>> just before the start comment sequence: if it's `comment` quit, else
>>>> process as usual.
>>>>
>>>> Since long comments are handled in lua.lua, i need to make that
>>>> style-checking function global.
>>>>
>>>> See attachement (result of `hg diff lexers/lexer.lua lexers/lua.lua >
>>>> fold.patch` from scintillua folder)
>>>
>>> Thanks for the patch, but I am not able to reproduce the bug using the
>>> latest 4.2. From your comments in the bug tracker, I presume you are
>>> still
>>> using 3.x? It's possible this bug was already fixed last August[1].
>>> Please
>>> let me know if this is not the case.
>>>
>>> mitchell
>>>
>>> [1]:
>>>
>>> http://code.google.com/p/scintillua/source/detail?r=9b82563097128e559d9168f49d5e84e4825728ec
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "textadept" group.
>>> To post to this group, send email to textadept.at.googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> textadept+unsubscribe.at.googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/textadept?hl=en.
>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "textadept" group.
>> To post to this group, send email to textadept.at.googlegroups.com.
>> To unsubscribe from this group, send email to
>> textadept+unsubscribe.at.googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/textadept?hl=en.
>>
>>
>
> mitchell
>
> --
> You received this message because you are subscribed to the Google Groups
> "textadept" group.
> To post to this group, send email to textadept.at.googlegroups.com.
> To unsubscribe from this group, send email to
> textadept+unsubscribe.at.googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/textadept?hl=en.
>
>
Received on Mon 28 Nov 2011 - 17:11:26 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:20:19 EST