forked from qt-creator/qt-creator
Revert "TextEditor: Hide LineNumberFilter implementation"
Fixes missing "Line in Current Document" locator filter.
Locator filters need to be created during startup.
This reverts commit 8af6d16b6c
.
Change-Id: I53ec1c1079b4a719169e8db95b6d77f703264b65
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -1,79 +1,69 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#include "linenumberfilter.h"
|
||||||
|
|
||||||
#include "texteditortr.h"
|
#include "texteditortr.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/locator/ilocatorfilter.h>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace TextEditor::Internal {
|
namespace TextEditor::Internal {
|
||||||
|
|
||||||
class LineNumberFilter : public ILocatorFilter
|
LineNumberFilter::LineNumberFilter()
|
||||||
{
|
{
|
||||||
public:
|
setId("Line in current document");
|
||||||
LineNumberFilter()
|
setDisplayName(Tr::tr("Line in Current Document"));
|
||||||
{
|
setDescription(Tr::tr("Jumps to the given line in the current document."));
|
||||||
setId("Line in current document");
|
setDefaultSearchText(Tr::tr("<line>:<column>"));
|
||||||
setDisplayName(Tr::tr("Line in Current Document"));
|
setPriority(High);
|
||||||
setDescription(Tr::tr("Jumps to the given line in the current document."));
|
setDefaultShortcutString("l");
|
||||||
setDefaultSearchText(Tr::tr("<line>:<column>"));
|
setDefaultIncludedByDefault(true);
|
||||||
setPriority(High);
|
}
|
||||||
setDefaultShortcutString("l");
|
|
||||||
setDefaultIncludedByDefault(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
LocatorMatcherTasks LineNumberFilter::matchers()
|
||||||
LocatorMatcherTasks matchers() final
|
{
|
||||||
{
|
using namespace Tasking;
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
TreeStorage<LocatorStorage> storage;
|
TreeStorage<LocatorStorage> storage;
|
||||||
|
|
||||||
const auto onSetup = [storage] {
|
const auto onSetup = [storage] {
|
||||||
const QStringList lineAndColumn = storage->input().split(':');
|
const QStringList lineAndColumn = storage->input().split(':');
|
||||||
int sectionCount = lineAndColumn.size();
|
int sectionCount = lineAndColumn.size();
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int column = 0;
|
int column = 0;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
if (sectionCount > 0)
|
if (sectionCount > 0)
|
||||||
line = lineAndColumn.at(0).toInt(&ok);
|
line = lineAndColumn.at(0).toInt(&ok);
|
||||||
if (ok && sectionCount > 1)
|
if (ok && sectionCount > 1)
|
||||||
column = lineAndColumn.at(1).toInt(&ok);
|
column = lineAndColumn.at(1).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
if (EditorManager::currentEditor() && (line > 0 || column > 0)) {
|
if (EditorManager::currentEditor() && (line > 0 || column > 0)) {
|
||||||
QString text;
|
QString text;
|
||||||
if (line > 0 && column > 0)
|
if (line > 0 && column > 0)
|
||||||
text = Tr::tr("Line %1, Column %2").arg(line).arg(column);
|
text = Tr::tr("Line %1, Column %2").arg(line).arg(column);
|
||||||
else if (line > 0)
|
else if (line > 0)
|
||||||
text = Tr::tr("Line %1").arg(line);
|
text = Tr::tr("Line %1").arg(line);
|
||||||
else
|
else
|
||||||
text = Tr::tr("Column %1").arg(column);
|
text = Tr::tr("Column %1").arg(column);
|
||||||
LocatorFilterEntry entry;
|
LocatorFilterEntry entry;
|
||||||
entry.displayName = text;
|
entry.displayName = text;
|
||||||
entry.acceptor = [line, targetColumn = column - 1] {
|
entry.acceptor = [line, targetColumn = column - 1] {
|
||||||
IEditor *editor = EditorManager::currentEditor();
|
IEditor *editor = EditorManager::currentEditor();
|
||||||
if (!editor)
|
if (!editor)
|
||||||
return AcceptResult();
|
|
||||||
EditorManager::addCurrentPositionToNavigationHistory();
|
|
||||||
editor->gotoLine(line < 1 ? editor->currentLine() : line, targetColumn);
|
|
||||||
EditorManager::activateEditor(editor);
|
|
||||||
return AcceptResult();
|
return AcceptResult();
|
||||||
};
|
EditorManager::addCurrentPositionToNavigationHistory();
|
||||||
storage->reportOutput({entry});
|
editor->gotoLine(line < 1 ? editor->currentLine() : line, targetColumn);
|
||||||
}
|
EditorManager::activateEditor(editor);
|
||||||
};
|
return AcceptResult();
|
||||||
return {{Sync(onSetup), storage}};
|
};
|
||||||
}
|
storage->reportOutput({entry});
|
||||||
};
|
}
|
||||||
|
};
|
||||||
ILocatorFilter *lineNumberFilter()
|
return {{Sync(onSetup), storage}};
|
||||||
{
|
|
||||||
static LineNumberFilter theLineNumberFilter;
|
|
||||||
return &theLineNumberFilter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TextEditor::Internal
|
} // namespace TextEditor::Internal
|
||||||
|
@@ -3,10 +3,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace Core { class ILocatorFilter; }
|
#include <coreplugin/locator/ilocatorfilter.h>
|
||||||
|
|
||||||
namespace TextEditor::Internal {
|
namespace TextEditor::Internal {
|
||||||
|
|
||||||
Core::ILocatorFilter *lineNumberFilter();
|
class LineNumberFilter : public Core::ILocatorFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LineNumberFilter();
|
||||||
|
|
||||||
} // TextEditor::Internal
|
private:
|
||||||
|
Core::LocatorMatcherTasks matchers() final;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace TextEditor::Internal
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "displaysettings.h"
|
#include "displaysettings.h"
|
||||||
#include "fontsettings.h"
|
#include "fontsettings.h"
|
||||||
#include "linenumberfilter.h"
|
#include "linenumberfilter.h"
|
||||||
|
#include "texteditorplugin.h"
|
||||||
#include "texteditortr.h"
|
#include "texteditortr.h"
|
||||||
#include "texteditorsettings.h"
|
#include "texteditorsettings.h"
|
||||||
|
|
||||||
@@ -179,7 +180,7 @@ void TextEditorActionHandlerPrivate::createActions()
|
|||||||
registerAction(SELECTALL,
|
registerAction(SELECTALL,
|
||||||
[] (TextEditorWidget *w) { w->selectAll(); }, true);
|
[] (TextEditorWidget *w) { w->selectAll(); }, true);
|
||||||
registerAction(GOTO, [] (TextEditorWidget *) {
|
registerAction(GOTO, [] (TextEditorWidget *) {
|
||||||
Core::LocatorManager::showFilter(lineNumberFilter());
|
Core::LocatorManager::showFilter(TextEditorPlugin::lineNumberFilter());
|
||||||
});
|
});
|
||||||
m_modifyingActions << registerAction(PRINT,
|
m_modifyingActions << registerAction(PRINT,
|
||||||
[] (TextEditorWidget *widget) { widget->print(Core::ICore::printer()); });
|
[] (TextEditorWidget *widget) { widget->print(Core::ICore::printer()); });
|
||||||
|
@@ -99,6 +99,7 @@ public:
|
|||||||
FilePath m_marginActionFileName;
|
FilePath m_marginActionFileName;
|
||||||
|
|
||||||
TextEditorSettings settings;
|
TextEditorSettings settings;
|
||||||
|
LineNumberFilter lineNumberFilter; // Goto line functionality for quick open
|
||||||
OutlineFactory outlineFactory;
|
OutlineFactory outlineFactory;
|
||||||
|
|
||||||
FindInFiles findInFilesFilter;
|
FindInFiles findInFilesFilter;
|
||||||
@@ -425,6 +426,11 @@ void TextEditorPlugin::extensionsInitialized()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LineNumberFilter *TextEditorPlugin::lineNumberFilter()
|
||||||
|
{
|
||||||
|
return &m_instance->d->lineNumberFilter;
|
||||||
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag TextEditorPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag TextEditorPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
Highlighter::handleShutdown();
|
Highlighter::handleShutdown();
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class LineNumberFilter;
|
||||||
|
|
||||||
class TextEditorPlugin final : public ExtensionSystem::IPlugin
|
class TextEditorPlugin final : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -18,6 +20,7 @@ public:
|
|||||||
~TextEditorPlugin() final;
|
~TextEditorPlugin() final;
|
||||||
|
|
||||||
static TextEditorPlugin *instance();
|
static TextEditorPlugin *instance();
|
||||||
|
static LineNumberFilter *lineNumberFilter();
|
||||||
|
|
||||||
ShutdownFlag aboutToShutdown() override;
|
ShutdownFlag aboutToShutdown() override;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user