Changeset View
Changeset View
Standalone View
Standalone View
autotests/src/kateview_test.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 423 | QCOMPARE(doc.text(), QString("line0\n" | |||
---|---|---|---|---|---|
425 | "line1\n" | 425 | "line1\n" | ||
426 | "\n" | 426 | "\n" | ||
427 | "line4")); | 427 | "line4")); | ||
428 | 428 | | |||
429 | QCOMPARE(view->cursorPosition(), KTextEditor::Cursor(3, 0)); | 429 | QCOMPARE(view->cursorPosition(), KTextEditor::Cursor(3, 0)); | ||
430 | QCOMPARE(view->selectionRange(), Range(2, 0, 3, 0)); | 430 | QCOMPARE(view->selectionRange(), Range(2, 0, 3, 0)); | ||
431 | } | 431 | } | ||
432 | 432 | | |||
433 | // test for bug https://bugs.kde.org/402594 | ||||
434 | void KateViewTest::testGotoMatchingBracket() | ||||
435 | { | ||||
436 | KTextEditor::DocumentPrivate doc(false, false); | ||||
437 | doc.setText("foo(bar)baz"); | ||||
438 | // 0123456789 | ||||
439 | | ||||
440 | KTextEditor::ViewPrivate *view = new KTextEditor::ViewPrivate(&doc, nullptr); | ||||
441 | const KTextEditor::Cursor cursor1(0, 3); // Starting point on open ( | ||||
442 | const KTextEditor::Cursor cursor2(0, 8); // Insert Mode differ slightly from... | ||||
443 | const KTextEditor::Cursor cursor3(0, 7); // Overwrite Mode | ||||
444 | | ||||
445 | doc.config()->setOvr(false); // Insert Mode | ||||
446 | | ||||
447 | view->setCursorPosition(cursor1); | ||||
448 | view->toMatchingBracket(); | ||||
449 | QCOMPARE(view->cursorPosition(), cursor2); | ||||
450 | view->toMatchingBracket(); | ||||
451 | QCOMPARE(view->cursorPosition(), cursor1); | ||||
452 | | ||||
453 | // Currently has it in Insert Mode also to work when the cursor is placed inside the parentheses | ||||
454 | view->setCursorPosition(cursor1 + KTextEditor::Cursor(0, 1)); | ||||
455 | view->toMatchingBracket(); | ||||
456 | QCOMPARE(view->cursorPosition(), cursor2); | ||||
457 | view->setCursorPosition(cursor2 + KTextEditor::Cursor(0, -1)); | ||||
458 | view->toMatchingBracket(); | ||||
459 | QCOMPARE(view->cursorPosition(), cursor1); | ||||
460 | | ||||
461 | doc.config()->setOvr(true);// Overwrite Mode | ||||
462 | | ||||
463 | view->setCursorPosition(cursor1); | ||||
464 | view->toMatchingBracket(); | ||||
465 | QCOMPARE(view->cursorPosition(), cursor3); | ||||
466 | view->toMatchingBracket(); | ||||
467 | QCOMPARE(view->cursorPosition(), cursor1); | ||||
468 | } | ||||
469 | | ||||
433 | // kate: indent-mode cstyle; indent-width 4; replace-tabs on; | 470 | // kate: indent-mode cstyle; indent-width 4; replace-tabs on; | ||
Context not available. |