Fix crash when replacing \n around empty lines
ClosedPublic

Authored by dhaumann on Aug 14 2018, 4:20 PM.

Details

Summary

The problem is that QString("").startsWith("") returns false.
Similarly, QString("").endsWith("") also returns false.
However, the code previously was assuming that both cases return true.

This is now fixed, and verified through unit tests.

BUG: 381080

This deprecates patch D6473

Test Plan

make && make test

Diff Detail

Repository
R39 KTextEditor
Branch
fix-replace-newline-empty-lines (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 1849
Build 1867: arc lint + arc unit
dhaumann created this revision.Aug 14 2018, 4:20 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptAug 14 2018, 4:20 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
dhaumann requested review of this revision.Aug 14 2018, 4:20 PM
cullmann accepted this revision.Aug 14 2018, 4:21 PM

Ok :P

This revision is now accepted and ready to land.Aug 14 2018, 4:21 PM
cullmann requested changes to this revision.Aug 14 2018, 4:22 PM

Better test with (a.isEmpty() && b.isEmpty()) for the special case to avoid comparing long lines again.

This revision now requires changes to proceed.Aug 14 2018, 4:22 PM
dhaumann updated this revision to Diff 39737.Aug 14 2018, 4:24 PM
  • Optimize by checking isEmpty()
cullmann accepted this revision.Aug 14 2018, 4:24 PM
This revision is now accepted and ready to land.Aug 14 2018, 4:24 PM
This revision was automatically updated to reflect the committed changes.