Changeset View
Changeset View
Standalone View
Standalone View
src/buffer/katetextcursor.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 68 | { | |||
---|---|---|---|---|---|
77 | if (m_block) { | 77 | if (m_block) { | ||
78 | m_block->insertCursor(this); | 78 | m_block->insertCursor(this); | ||
79 | } | 79 | } | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | void TextCursor::setPosition(const KTextEditor::Cursor &position, bool init) | 82 | void TextCursor::setPosition(const KTextEditor::Cursor &position, bool init) | ||
83 | { | 83 | { | ||
84 | // any change or init? else do nothing | 84 | // any change or init? else do nothing | ||
85 | if (!init && position.line() == line() && position.column() == m_column) { | 85 | if (!init && position.line() == line()) { | ||
86 | // simple case: 1:1 equal | ||||
87 | if (position.column() == m_column) | ||||
86 | return; | 88 | return; | ||
89 | | ||||
90 | // ok, too: both old and new column are valid, we can just adjust the column and be done | ||||
91 | if (position.column() >= 0 && m_column >= 0) { | ||||
92 | m_column = position.column(); | ||||
93 | return; | ||||
94 | } | ||||
95 | | ||||
96 | // else: we need to handle the change in a more complex way, new or old column are not valid! | ||||
87 | } | 97 | } | ||
88 | 98 | | |||
89 | // remove cursor from old block in any case | 99 | // remove cursor from old block in any case | ||
90 | if (m_block) { | 100 | if (m_block) { | ||
91 | m_block->removeCursor(this); | 101 | m_block->removeCursor(this); | ||
92 | } | 102 | } | ||
93 | 103 | | |||
94 | // first: validate the line and column, else invalid | 104 | // first: validate the line and column, else invalid | ||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |