Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewinternal.cpp
Show First 20 Lines • Show All 759 Lines • ▼ Show 20 Line(s) | 754 | { | |||
---|---|---|---|---|---|
760 | 760 | | |||
761 | if (viewLine < 0 || viewLine >= cache()->viewCacheLineCount()) { | 761 | if (viewLine < 0 || viewLine >= cache()->viewCacheLineCount()) { | ||
762 | return QPoint(-1, -1); | 762 | return QPoint(-1, -1); | ||
763 | } | 763 | } | ||
764 | 764 | | |||
765 | const int y = (int)viewLine * renderer()->lineHeight(); | 765 | const int y = (int)viewLine * renderer()->lineHeight(); | ||
766 | 766 | | |||
767 | KateTextLayout layout = cache()->viewLine(viewLine); | 767 | KateTextLayout layout = cache()->viewLine(viewLine); | ||
768 | | ||||
769 | if (cursor.column() > layout.lineLayout().textLength()) { | ||||
770 | return QPoint(-1, -1); | ||||
771 | } | ||||
772 | | ||||
768 | int x = 0; | 773 | int x = 0; | ||
769 | 774 | | |||
770 | // only set x value if we have a valid layout (bug #171027) | 775 | // only set x value if we have a valid layout (bug #171027) | ||
771 | if (layout.isValid()) { | 776 | if (layout.isValid()) { | ||
772 | x = (int)layout.lineLayout().cursorToX(cursor.column()); | 777 | x = (int)layout.lineLayout().cursorToX(cursor.column()); | ||
773 | } | 778 | } | ||
774 | // else | 779 | // else | ||
775 | // qCDebug(LOG_KTE) << "Invalid Layout"; | 780 | // qCDebug(LOG_KTE) << "Invalid Layout"; | ||
▲ Show 20 Lines • Show All 2008 Lines • ▼ Show 20 Line(s) | 2782 | { | |||
2784 | } | 2789 | } | ||
2785 | coord.rx() += startX(); | 2790 | coord.rx() += startX(); | ||
2786 | 2791 | | |||
2787 | const KateTextLayout &thisLine = yToKateTextLayout(coord.y()); | 2792 | const KateTextLayout &thisLine = yToKateTextLayout(coord.y()); | ||
2788 | if (thisLine.isValid()) { | 2793 | if (thisLine.isValid()) { | ||
2789 | ret = renderer()->xToCursor(thisLine, coord.x(), !m_view->wrapCursor()); | 2794 | ret = renderer()->xToCursor(thisLine, coord.x(), !m_view->wrapCursor()); | ||
2790 | } | 2795 | } | ||
2791 | 2796 | | |||
2792 | if (ret.column() == view()->document()->lineLength(ret.line())) { | 2797 | if (ret.column() > view()->document()->lineLength(ret.line())) { | ||
2793 | // The cursor is beyond the end of the line; in that case the renderer | 2798 | // The cursor is beyond the end of the line; in that case the renderer | ||
2794 | // gives the index of the character behind the last one. | 2799 | // gives the index of the character behind the last one. | ||
2795 | return KTextEditor::Cursor::invalid(); | 2800 | return KTextEditor::Cursor::invalid(); | ||
2796 | } | 2801 | } | ||
2797 | 2802 | | |||
2798 | return ret; | 2803 | return ret; | ||
2799 | } | 2804 | } | ||
2800 | 2805 | | |||
▲ Show 20 Lines • Show All 968 Lines • Show Last 20 Lines |