| 321 | } |
| 322 | |
| 323 | void PatchHighlighter::textRemoved( KTextEditor::Document* doc, const KTextEditor::Range& range, const QString& oldText ) { |
| 324 | Q_ASSERT(range.isValid()); |
| 325 | if ( m_applying ) { // Do not interfere with patch application |
| 326 | return; |
| 327 | } |
| 328 | qCDebug(PLUGIN_PATCHREVIEW) << "removal range" << range; |
| 329 | qCDebug(PLUGIN_PATCHREVIEW) << "removed text" << oldText; |
| 330 | |
| 331 | KTextEditor::Cursor cursor = range.start(); |
| 332 | int startLine = cursor.line(); |
| 333 | QStringList removedLines; |
| 334 | QStringList remainingLines; |
| 335 | if (startLine > 0) { |
| 336 | QString above = doc->line(--startLine); |
| 337 | removedLines << above; |
| 338 | remainingLines << above; |
| 339 | } |
| 340 | |
| 341 | const QString changed = doc->line(cursor.line()) + QLatin1Char('\n'); |
| 342 | const QStringView changedView = changed; |
| 343 | Q_ASSERT(cursor.column() <= changed.size()); |
| 344 | removedLines << changedView.first(cursor.column()) + oldText + changedView.sliced(cursor.column()); |
| 345 | remainingLines << changed; |
| 346 | |
| 347 | if (doc->documentRange().end().line() > cursor.line()) { |
| 348 | QString below = doc->line(cursor.line() + 1); |
| 349 | removedLines << below; |
| 350 | remainingLines << below; |
| 351 | } |
| 352 | |
| 353 | performContentChange(doc, removedLines, remainingLines, startLine + 1); |
| 354 | } |
| 355 | |
| 356 | void PatchHighlighter::newlineRemoved(KTextEditor::Document* doc, int line) { |
| 357 | if ( m_applying ) { // Do not interfere with patch application |