Always rehiglhight() after definition was changed
AbandonedPublic

Authored by meven on Nov 15 2019, 2:08 PM.

Details

Summary

When setting definition, Rehighlight text even if the definition has not changed.
Useful when the dummy default definition is set, so that highlight is run even in this case.

BUG: 409380
FIXED-IN: 5.65

Test Plan

ctest
In dolphin, text files content is readable in thumbnails.

Diff Detail

Repository
R216 Syntax Highlighting
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 18826
Build 18844: arc lint + arc unit
meven created this revision.Nov 15 2019, 2:08 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptNov 15 2019, 2:08 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
meven requested review of this revision.Nov 15 2019, 2:08 PM

Hmm, I am not sure this doesn't regress cases that rely on setDefinition being "cheap" for the nop case.
Is there no other way to trigger re-highlight for the wanted case?

Can't you call rehighlight() yourself after calling setDefinition()?

Btw, tanks for looking into this!

Can't you call rehighlight() yourself after calling setDefinition()?

Btw, tanks for looking into this!

I have done so in D25323.
But I meant to open this one as well to figure out which way to go, user side fix or lib fix ?
I would favor the lib fix as it seems it might save some users the trouble of adding a workaround because no definition is found just to get highlight like D25323 does.
Kate has such a workaround as well in KateSyntaxHighlight I believe.

Hmm, the use case is that it re-highlights if you set an invalid definition?
Perhaps one should just trigger rehighlight here just for that case, too.

meven added a comment.Nov 18 2019, 4:55 PM

Hmm, the use case is that it re-highlights if you set an invalid definition?

Here it rehighlight if the definition has changed definition() != def.
But since the current definition m_definition has initially the value Definition(), it is the same as the invalid default definition returned by Repository::definitionForFileName (set in RepositoryPrivate::load line 161) and does not call rehighlight.

Perhaps one should just trigger rehighlight here just for that case, too.

So the fix does not really depend on the definition being valid or invalid.

Perhaps there is a better way to fix this.

meven added a comment.Dec 2 2019, 3:40 PM

Hmm, the use case is that it re-highlights if you set an invalid definition?

Here it rehighlight if the definition has changed definition() != def.
But since the current definition m_definition has initially the value Definition(), it is the same as the invalid default definition returned by Repository::definitionForFileName (set in RepositoryPrivate::load line 161) and does not call rehighlight.

Perhaps one should just trigger rehighlight here just for that case, too.

So the fix does not really depend on the definition being valid or invalid.

Perhaps there is a better way to fix this.

Any thought from a SyntaxHighlighter maintainer ?
I hope I have made the issue clear enough.

meven abandoned this revision.Dec 14 2019, 7:23 AM

Fixed in thumnail creator in D25891