forked from qt-creator/qt-creator
Added `editorKind' to BaseTextEditor::openEditorAt(). We need it to force the CPPEDITOR kind
when opening files from the C++ editor (e.g. when the user press F2 on #include <QMutex>).
This commit is contained in:
@@ -485,7 +485,7 @@ void CPPEditor::jumpToDefinition()
|
||||
unsigned lineno = tc.blockNumber() + 1;
|
||||
foreach (const Document::Include &incl, doc->includes()) {
|
||||
if (incl.line() == lineno) {
|
||||
if (TextEditor::BaseTextEditor::openEditorAt(incl.fileName(), 0, 0))
|
||||
if (openCppEditorAt(incl.fileName(), 0, 0))
|
||||
return; // done
|
||||
break;
|
||||
}
|
||||
@@ -525,7 +525,7 @@ void CPPEditor::jumpToDefinition()
|
||||
QList<Symbol *> candidates = context.resolve(namedType->name());
|
||||
if (!candidates.isEmpty()) {
|
||||
Symbol *s = candidates.takeFirst();
|
||||
openEditorAt(s->fileName(), s->line(), s->column());
|
||||
openCppEditorAt(s->fileName(), s->line(), s->column());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -534,7 +534,7 @@ void CPPEditor::jumpToDefinition()
|
||||
if (use.contains(endOfName - 1)) {
|
||||
const Macro ¯o = use.macro();
|
||||
const QString fileName = QString::fromUtf8(macro.fileName);
|
||||
if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0))
|
||||
if (openCppEditorAt(fileName, macro.line, 0))
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
@@ -836,8 +836,15 @@ int CPPEditor::endOfNameUnderCursor()
|
||||
return pos;
|
||||
}
|
||||
|
||||
TextEditor::ITextEditor *CPPEditor::openCppEditorAt(const QString &fileName,
|
||||
int line, int column)
|
||||
{
|
||||
return TextEditor::BaseTextEditor::openEditorAt(fileName, line, column,
|
||||
Constants::C_CPPEDITOR);
|
||||
}
|
||||
|
||||
bool CPPEditor::openEditorAt(Symbol *s)
|
||||
{
|
||||
const QString fileName = QString::fromUtf8(s->fileName(), s->fileNameLength());
|
||||
return TextEditor::BaseTextEditor::openEditorAt(fileName, s->line(), s->column());
|
||||
return openCppEditorAt(fileName, s->line(), s->column());
|
||||
}
|
||||
|
||||
@@ -123,6 +123,9 @@ private:
|
||||
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol);
|
||||
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
||||
|
||||
TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line,
|
||||
int column = 0);
|
||||
|
||||
int previousBlockState(QTextBlock block) const;
|
||||
QTextCursor moveToPreviousToken(QTextCursor::MoveMode mode) const;
|
||||
QTextCursor moveToNextToken(QTextCursor::MoveMode mode) const;
|
||||
|
||||
@@ -128,12 +128,13 @@ protected:
|
||||
|
||||
ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName,
|
||||
int line,
|
||||
int column)
|
||||
int column,
|
||||
const QString &editorKind)
|
||||
{
|
||||
Core::EditorManager *editorManager =
|
||||
ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager();
|
||||
editorManager->addCurrentPositionToNavigationHistory(true);
|
||||
Core::IEditor *editor = editorManager->openEditor(fileName, QString(), true);
|
||||
Core::IEditor *editor = editorManager->openEditor(fileName, editorKind, true);
|
||||
TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor);
|
||||
if (texteditor) {
|
||||
texteditor->gotoLine(line, column);
|
||||
@@ -714,7 +715,7 @@ void BaseTextEditor::moveLineUpDown(bool up)
|
||||
QString text = move.selectedText();
|
||||
move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||
move.removeSelectedText();
|
||||
|
||||
|
||||
if (up) {
|
||||
move.movePosition(QTextCursor::PreviousBlock);
|
||||
move.insertBlock();
|
||||
@@ -729,7 +730,7 @@ void BaseTextEditor::moveLineUpDown(bool up)
|
||||
move.insertBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int start = move.position();
|
||||
move.clearSelection();
|
||||
move.insertText(text);
|
||||
@@ -3376,7 +3377,7 @@ void BaseTextEditorPrivate::moveCursorVisible()
|
||||
if (!cursor.block().isVisible()) {
|
||||
cursor.setVisualNavigation(true);
|
||||
cursor.movePosition(QTextCursor::PreviousBlock);
|
||||
q->setTextCursor(cursor);
|
||||
q->setTextCursor(cursor);
|
||||
}
|
||||
q->ensureCursorVisible();
|
||||
}
|
||||
|
||||
@@ -230,7 +230,8 @@ public:
|
||||
BaseTextEditor(QWidget *parent);
|
||||
~BaseTextEditor();
|
||||
|
||||
static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0);
|
||||
static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0,
|
||||
const QString &editorKind = QString());
|
||||
|
||||
// EditorInterface
|
||||
Core::IFile * file();
|
||||
|
||||
Reference in New Issue
Block a user