forked from qt-creator/qt-creator
fakevim: Commands '[z' and ']z' to move to top or bottom of fold
Commands '[z' and ']z' to move [count] times to top or bottom of current folds. Change-Id: Ia087e47bd5f9d63a2b9a4b2ffd3fc57559dfba6b Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -855,7 +855,7 @@ private slots:
|
||||
void foldToggle(int depth);
|
||||
void foldAll(bool fold);
|
||||
void fold(int depth, bool fold);
|
||||
void foldGoTo(int count);
|
||||
void foldGoTo(int count, bool current);
|
||||
void jumpToGlobalMark(QChar mark, bool backTickMode, const QString &fileName);
|
||||
void showSettingsDialog();
|
||||
void maybeReadVimRc();
|
||||
@@ -1452,7 +1452,7 @@ void FakeVimPluginPrivate::fold(int depth, bool fold)
|
||||
documentLayout->emitDocumentSizeChanged();
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::foldGoTo(int count)
|
||||
void FakeVimPluginPrivate::foldGoTo(int count, bool current)
|
||||
{
|
||||
IEditor *ieditor = EditorManager::currentEditor();
|
||||
BaseTextEditorWidget *editor = qobject_cast<BaseTextEditorWidget *>(ieditor->widget());
|
||||
@@ -1464,17 +1464,23 @@ void FakeVimPluginPrivate::foldGoTo(int count)
|
||||
int pos = -1;
|
||||
if (count > 0) {
|
||||
int repeat = count;
|
||||
QTextBlock prevBlock = block;
|
||||
block = block.next();
|
||||
QTextBlock prevBlock = block;
|
||||
int indent = BaseTextDocumentLayout::foldingIndent(block);
|
||||
block = block.next();
|
||||
while (block.isValid()) {
|
||||
int newIndent = BaseTextDocumentLayout::foldingIndent(block);
|
||||
if (prevBlock.isVisible() && indent < newIndent) {
|
||||
pos = prevBlock.position();
|
||||
if (--repeat <= 0)
|
||||
break;
|
||||
if (current ? indent > newIndent : indent < newIndent) {
|
||||
if (prevBlock.isVisible()) {
|
||||
pos = prevBlock.position();
|
||||
if (--repeat <= 0)
|
||||
break;
|
||||
} else if (current) {
|
||||
indent = newIndent;
|
||||
}
|
||||
}
|
||||
indent = newIndent;
|
||||
if (!current)
|
||||
indent = newIndent;
|
||||
prevBlock = block;
|
||||
block = block.next();
|
||||
}
|
||||
@@ -1484,14 +1490,15 @@ void FakeVimPluginPrivate::foldGoTo(int count)
|
||||
block = block.previous();
|
||||
while (block.isValid()) {
|
||||
int newIndent = BaseTextDocumentLayout::foldingIndent(block);
|
||||
if (indent < newIndent) {
|
||||
if (current ? indent > newIndent : indent < newIndent) {
|
||||
while (block.isValid() && !block.isVisible())
|
||||
block = block.previous();
|
||||
pos = block.position();
|
||||
if (--repeat <= 0)
|
||||
break;
|
||||
}
|
||||
indent = newIndent;
|
||||
if (!current)
|
||||
indent = newIndent;
|
||||
block = block.previous();
|
||||
}
|
||||
}
|
||||
@@ -1591,8 +1598,8 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
||||
SLOT(foldAll(bool)));
|
||||
connect(handler, SIGNAL(fold(int,bool)),
|
||||
SLOT(fold(int,bool)));
|
||||
connect(handler, SIGNAL(foldGoTo(int)),
|
||||
SLOT(foldGoTo(int)));
|
||||
connect(handler, SIGNAL(foldGoTo(int, bool)),
|
||||
SLOT(foldGoTo(int, bool)));
|
||||
connect(handler, SIGNAL(jumpToGlobalMark(QChar,bool,QString)),
|
||||
SLOT(jumpToGlobalMark(QChar,bool,QString)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user