Summary: | It's impossible to fold (or generaly highlight) text written for human beings | ||
---|---|---|---|
Product: | [Applications] kate | Reporter: | Hulahup <bruno.vasselle> |
Component: | folding | Assignee: | KWrite Developers <kwrite-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | 3.10.4 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kate/8300891b72f7716f25494d42ab01edba36e7bf12 | Version Fixed In: | 4.12 |
Sentry Crash Report: | |||
Attachments: |
Kind of Wiki highlighting; considers line beginning with "= " as section headers
Original message with a "= " fixed - testcase [PATCH] Set end-of-region to the end of the previous line when it occurs at column 0 |
Description
Hulahup
2013-07-07 18:16:48 UTC
Possible fix: https://git.reviewboard.kde.org/r/111540/ Git commit 8300891b72f7716f25494d42ab01edba36e7bf12 by Dominik Haumann. Committed on 17/07/2013 at 07:40. Pushed by dhaumann into branch 'master'. allow endRegion and startRegion in combination with lookAhead FIXED-IN: 4.12 REVIEW: 111540 M +44 -39 part/syntax/katehighlight.cpp http://commits.kde.org/kate/8300891b72f7716f25494d42ab01edba36e7bf12 Hi Dominik Thanks for your patch. It looks like: - it succeeds at ending the region before the matching - but fails at ending it at the end of the line before in case the matching occurs at the very beginning of a line Could you confirm ? I'm attaching an highlighting XML and a slightly modified version of the original message for test purposes. Created attachment 81221 [details]
Kind of Wiki highlighting; considers line beginning with "= " as section headers
Highlighting code announced in the previous message
Created attachment 81222 [details]
Original message with a "= " fixed - testcase
Created attachment 81227 [details]
[PATCH] Set end-of-region to the end of the previous line when it occurs at column 0
Dominik
Here's a patch to move the "end of region" to the end of previous line when it is at column is 0.
It is not benign: it changes in the doHighlight API, in the sense that it removes "const" on "prevLine". It's necessary however.
I don't have the whole picture: using the patch may require patches somewhere else.
I've tested it against the previous attachments, and it works as expected.
Review request: https://git.reviewboard.kde.org/r/111628/ Thanks, Dominik @Hulahup: I've added a comment to https://git.reviewboard.kde.org/r/111628/ In essence, I think there are corner cases where the highlighting would break: Say line 5 adds a closing fold to line 4, and line 5 is rehighlighted. Then, each rehighlight adds another closing fold to line 4 (if line 4 is not rehighlighted). In other words, the closing folds add up, which is the wrong behavior. So a correct patch would need to mark line 5 as depending on the previous line, so an extension to KateTextLine is needed. This then indeed should work. Comments welcome. @Dominik The use case you're pointing out may also presumably dealt with an ad-hoc analysis at addAttribute level, instead of line dependencies, doesn't it? Anyway, it makes me feel the patch is simply at the wrong place. I was originally searching for where the actual folding is performed, not where lines are analysed, but I could not find my way in the code. What do you think? If this fits better, could you guide me through the code? |