This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Kate Editor: Code Folding

Tags: None
(comma "," separated)
User avatar
jamesromance
Registered Member
Posts
6
Karma
0
OS

Kate Editor: Code Folding

Sun Aug 21, 2022 9:19 pm
Currently Kate Editors folds code like this...

BEFORE:
▼.data
blah
blah
blah
.code

AFTER:
►.data
.code

Is there a way to get the editor to fold the entire section, i.e. --

AFTER:
►.data
User avatar
chiefbromden
Registered Member
Posts
39
Karma
0
OS

Re: Kate Editor: Code Folding

Sun Aug 21, 2022 11:45 pm
I'm not sure what you mean.
Do you mean nested code?

Code: Select all
a = 1
b = 2
c = 3
def abc():
    print()
    def efg():
        print()
        pass
class hij():
    some = 'stuff'
User avatar
jamesromance
Registered Member
Posts
6
Karma
0
OS

Re: Kate Editor: Code Folding

Mon Aug 22, 2022 7:40 pm
A picture might be worth a thousand words but this forum won't let me post images. Do not add or subtract anything to what I posted because it represents exactly what I am seeing, i.e. -- when performing a code fold, the code folding mechanism won't include the last line in the fold, even though the last line is part of the endRegion search term

Code: Select all
        <RegExpr attribute="Keyword" context="#stay" String="(\.data)($)" beginRegion="DataRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="(\.code)($)" endRegion="DataRegion"/>


BEFORE CODE FOLDING:
▼.data
blah
blah
blah
.code

AFTER CODE FOLDING:
►.data
.code

WHAT IT SHOULD BE:
►.data
User avatar
chiefbromden
Registered Member
Posts
39
Karma
0
OS

Re: Kate Editor: Code Folding

Mon Aug 22, 2022 9:08 pm
Code: Select all
<RegExpr attribute="Keyword" context="#stay" String="(\.data)($)" beginRegion="DataRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="(\.code)($)" endRegion="DataRegion"/>

Now I get it: you're writing your own syntax highlighting file. Sorry, my mistake.
Look. I'm not an expert, but I had a similar problem using Ply. The '.' (dot) is greedy on a Regular Expression, depending on the RegEx,it consumes every character until the end of the string. I don't know what kind of syntax you're writing but if you can use other character that '.', do it. I hope this is helpful, if is not it goes beyond my understanding.
User avatar
jamesromance
Registered Member
Posts
6
Karma
0
OS

Re: Kate Editor: Code Folding

Mon Aug 22, 2022 10:38 pm
The '.' (dot) is greedy on a Regular Expression, depending on the RegEx,it consumes every character until the end of the string.. I don't know what kind of syntax you're writing but if you can use other character that '.', do it


1) The dot can be greedy but that problem is the Kate syntax engine is never greedy when it should be.

2) When the dot is prefixed with a "\" it becomes just a literal dot instead of a directive for "match any char".

I hope this is helpful, if is not it goes beyond my understanding


Maybe you can't help with that but maybe you can find a way to escalate this issue for me? Just so you know, this isn't a bug I can report, this is a flaw. Code folding is useless for folding functions if it isn't greedy because it clutters the text. Maybe if the development team issued another rule besides #stay and #pop, maybe #greedy? If I could post a pic I that would make this obvious.
User avatar
chiefbromden
Registered Member
Posts
39
Karma
0
OS

Re: Kate Editor: Code Folding

Tue Aug 23, 2022 2:55 pm
1) The dot can be greedy but that problem is the Kate syntax engine is never greedy when it should be.

You're right, it's been a while since the last time I deal with RegEx, I didn't think it right.
2) When the dot is prefixed with a "\" it becomes just a literal dot instead of a directive for "match any char".

Yeah I knew that, I did mention it just to point out the role of the dot.
Maybe you can't help with that but maybe you can find a way to escalate this issue for me?

I got here three days ago, I wouldn't have a problem but I don't have enough leverage. Maybe somebody else read this thread and give you a hand. I don't know who is who here, but you can talk to one the moderators. Or you can think on contributing to the Kate Team take a look at their support page.

As for the images, you can try upload to a free hosting site like this one and put the link here. I didn't test it but let me know if it worked.
User avatar
jamesromance
Registered Member
Posts
6
Karma
0
OS

Re: Kate Editor: Code Folding

Tue Aug 23, 2022 5:12 pm
You're right, it's been a while since the last time I deal with RegEx, I didn't think it right.


I didn't mean to come across as a know-it-all, but I can't always tell who is a noobie or not.

I got here three days ago, I wouldn't have a problem but I don't have enough leverage. Maybe somebody else read this thread and give you a hand. I don't know who is who here, but you can talk to one the moderators. Or you can think on contributing to the Kate Team take a look at their support page.


It says the bug report system is also for reporting your wishes, so that does sound like it would get more visibility to the right people than a forum might, especially when the flaw I'm seeing isn't actually a bug since it looks like it is done on purpose.

As for the images, you can try upload to a free hosting site like this one and put the link here. I didn't test it but let me know if it worked.


Wow! Why couldn't I find that on my own?

Now you know why I selected your response as the answer. Good job!

PS -- Let's see how it works: Image
User avatar
jamesromance
Registered Member
Posts
6
Karma
0
OS

Re: Kate Editor: Code Folding

Thu Aug 25, 2022 8:41 pm
Sorry to uncheck the answered mark, but while your answer was a great idea, I'm not really sure it will actually solve anything until someone working at Kate responds to my issue.
User avatar
chiefbromden
Registered Member
Posts
39
Karma
0
OS

Re: Kate Editor: Code Folding

Sat Aug 27, 2022 2:46 pm
That's fine, I hope they respond quickly. Let me know if they do.
User avatar
jamesromance
Registered Member
Posts
6
Karma
0
OS
No one has replied to this serious issue.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kesang, Yahoo [Bot]