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;
|
unsigned lineno = tc.blockNumber() + 1;
|
||||||
foreach (const Document::Include &incl, doc->includes()) {
|
foreach (const Document::Include &incl, doc->includes()) {
|
||||||
if (incl.line() == lineno) {
|
if (incl.line() == lineno) {
|
||||||
if (TextEditor::BaseTextEditor::openEditorAt(incl.fileName(), 0, 0))
|
if (openCppEditorAt(incl.fileName(), 0, 0))
|
||||||
return; // done
|
return; // done
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,7 @@ void CPPEditor::jumpToDefinition()
|
|||||||
QList<Symbol *> candidates = context.resolve(namedType->name());
|
QList<Symbol *> candidates = context.resolve(namedType->name());
|
||||||
if (!candidates.isEmpty()) {
|
if (!candidates.isEmpty()) {
|
||||||
Symbol *s = candidates.takeFirst();
|
Symbol *s = candidates.takeFirst();
|
||||||
openEditorAt(s->fileName(), s->line(), s->column());
|
openCppEditorAt(s->fileName(), s->line(), s->column());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -534,7 +534,7 @@ void CPPEditor::jumpToDefinition()
|
|||||||
if (use.contains(endOfName - 1)) {
|
if (use.contains(endOfName - 1)) {
|
||||||
const Macro ¯o = use.macro();
|
const Macro ¯o = use.macro();
|
||||||
const QString fileName = QString::fromUtf8(macro.fileName);
|
const QString fileName = QString::fromUtf8(macro.fileName);
|
||||||
if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0))
|
if (openCppEditorAt(fileName, macro.line, 0))
|
||||||
return; // done
|
return; // done
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -836,8 +836,15 @@ int CPPEditor::endOfNameUnderCursor()
|
|||||||
return pos;
|
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)
|
bool CPPEditor::openEditorAt(Symbol *s)
|
||||||
{
|
{
|
||||||
const QString fileName = QString::fromUtf8(s->fileName(), s->fileNameLength());
|
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);
|
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol);
|
||||||
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
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;
|
int previousBlockState(QTextBlock block) const;
|
||||||
QTextCursor moveToPreviousToken(QTextCursor::MoveMode mode) const;
|
QTextCursor moveToPreviousToken(QTextCursor::MoveMode mode) const;
|
||||||
QTextCursor moveToNextToken(QTextCursor::MoveMode mode) const;
|
QTextCursor moveToNextToken(QTextCursor::MoveMode mode) const;
|
||||||
|
|||||||
@@ -128,12 +128,13 @@ protected:
|
|||||||
|
|
||||||
ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName,
|
ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName,
|
||||||
int line,
|
int line,
|
||||||
int column)
|
int column,
|
||||||
|
const QString &editorKind)
|
||||||
{
|
{
|
||||||
Core::EditorManager *editorManager =
|
Core::EditorManager *editorManager =
|
||||||
ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager();
|
ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager();
|
||||||
editorManager->addCurrentPositionToNavigationHistory(true);
|
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);
|
TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor);
|
||||||
if (texteditor) {
|
if (texteditor) {
|
||||||
texteditor->gotoLine(line, column);
|
texteditor->gotoLine(line, column);
|
||||||
@@ -714,7 +715,7 @@ void BaseTextEditor::moveLineUpDown(bool up)
|
|||||||
QString text = move.selectedText();
|
QString text = move.selectedText();
|
||||||
move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||||
move.removeSelectedText();
|
move.removeSelectedText();
|
||||||
|
|
||||||
if (up) {
|
if (up) {
|
||||||
move.movePosition(QTextCursor::PreviousBlock);
|
move.movePosition(QTextCursor::PreviousBlock);
|
||||||
move.insertBlock();
|
move.insertBlock();
|
||||||
@@ -729,7 +730,7 @@ void BaseTextEditor::moveLineUpDown(bool up)
|
|||||||
move.insertBlock();
|
move.insertBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int start = move.position();
|
int start = move.position();
|
||||||
move.clearSelection();
|
move.clearSelection();
|
||||||
move.insertText(text);
|
move.insertText(text);
|
||||||
@@ -3376,7 +3377,7 @@ void BaseTextEditorPrivate::moveCursorVisible()
|
|||||||
if (!cursor.block().isVisible()) {
|
if (!cursor.block().isVisible()) {
|
||||||
cursor.setVisualNavigation(true);
|
cursor.setVisualNavigation(true);
|
||||||
cursor.movePosition(QTextCursor::PreviousBlock);
|
cursor.movePosition(QTextCursor::PreviousBlock);
|
||||||
q->setTextCursor(cursor);
|
q->setTextCursor(cursor);
|
||||||
}
|
}
|
||||||
q->ensureCursorVisible();
|
q->ensureCursorVisible();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,8 @@ public:
|
|||||||
BaseTextEditor(QWidget *parent);
|
BaseTextEditor(QWidget *parent);
|
||||||
~BaseTextEditor();
|
~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
|
// EditorInterface
|
||||||
Core::IFile * file();
|
Core::IFile * file();
|
||||||
|
|||||||
Reference in New Issue
Block a user