Commit 7b8e0a38 authored by Michel Ludwig's avatar Michel Ludwig
Browse files

Fix the move-to-next-bullet action

If the cursor is positioned at a bullet and the move-to-next-bullet action is
triggered, the cursor will jump to the next bullet if the current bullet hasn't
been 'highlighted' yet.

BUG: 316332
parent c2d42978
/***********************************************************************************************
date : Mar 12 2007
version : 0.46
copyright : (C) 2004-2007 by Holger Danielsson (holger.danielsson@versanet.de)
2008-2012 by Michel Ludwig (michel.ludwig@kdemail.net)
Copyright (C) 2004-2007 by Holger Danielsson (holger.danielsson@versanet.de)
2008-2013 by Michel Ludwig (michel.ludwig@kdemail.net)
***********************************************************************************************/
/***************************************************************************
......@@ -1551,8 +1549,6 @@ void EditorExtension::gotoBullet(bool backwards, KTextEditor::View *view)
return;
}
int row, col;
// get current position
KTextEditor::Document *doc = view->document();
......@@ -1562,17 +1558,21 @@ void EditorExtension::gotoBullet(bool backwards, KTextEditor::View *view)
}
KTextEditor::Cursor cursor = view->cursorPosition();
row = cursor.line();
col = cursor.column();
KTextEditor::Search::SearchOptions searchOptions = (backwards) ? KTextEditor::Search::Backwards : KTextEditor::Search::Default;
KTextEditor::Range searchRange;
if(backwards) {
searchRange = KTextEditor::Range(KTextEditor::Cursor(0, 0), KTextEditor::Cursor(row, col));
searchRange = KTextEditor::Range(KTextEditor::Cursor(0, 0), cursor);
}
else {
searchRange = KTextEditor::Range(KTextEditor::Cursor(row, col), doc->documentEnd());
const KTextEditor::Cursor nextCursorPosition(cursor.line(), cursor.column() + 1);
if((doc->character(cursor) == s_bullet_char) // we are already at a bullet
&& view->selection()
&& view->selectionRange() == KTextEditor::Range(cursor, nextCursorPosition)) { // which has been 'highlighted'
cursor = nextCursorPosition; // search for the next bullet
}
searchRange = KTextEditor::Range(cursor, doc->documentEnd());
}
QVector<KTextEditor::Range> foundRanges = iface->searchText(searchRange, s_bullet, searchOptions);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment