MCPcopy Create free account
hub / github.com/KDE/kdevelop / textInserted

Method textInserted

plugins/patchreview/patchhighlighter.cpp:455–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455void PatchHighlighter::textInserted(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor, const QString& text) {
456 Q_ASSERT(cursor.isValid());
457 if ( m_applying ) { // Do not interfere with patch application
458 return;
459 }
460
461 int startLine = cursor.line();
462 int endColumn = cursor.column() + text.length();
463
464 qCDebug(PLUGIN_PATCHREVIEW) << "insertion range" <<
465 KTextEditor::Range(cursor, KTextEditor::Cursor(startLine, endColumn));
466 qCDebug(PLUGIN_PATCHREVIEW) << "inserted text" << text;
467
468 QStringList removedLines;
469 QStringList insertedLines;
470 if (startLine > 0) {
471 const QString above = doc->line(--startLine) + QLatin1Char('\n');
472 removedLines << above;
473 insertedLines << above;
474 }
475
476 const QString changed = doc->line(cursor.line()) + QLatin1Char('\n');
477 const QStringView changedView = changed;
478 Q_ASSERT(endColumn <= changed.size());
479 removedLines << changedView.first(cursor.column()) + changedView.sliced(endColumn);
480 insertedLines << changed;
481
482 if (doc->documentRange().end().line() > cursor.line()) {
483 const QString below = doc->line(cursor.line() + 1) + QLatin1Char('\n');
484 removedLines << below;
485 insertedLines << below;
486 }
487
488 performContentChange(doc, removedLines, insertedLines, startLine + 1);
489}
490
491void PatchHighlighter::newlineInserted(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor)
492{

Callers

nothing calls this directly

Calls 9

RangeClass · 0.70
CursorClass · 0.70
isValidMethod · 0.45
lineMethod · 0.45
columnMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45
firstMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected