forked from qt-creator/qt-creator
C++ Editor: fixed cursor positioning after quickfix action.
This commit is contained in:
@@ -95,7 +95,9 @@ public:
|
||||
targetFile.change(target);
|
||||
targetFile.indent(Utils::ChangeSet::Range(targetPosition2, targetPosition1));
|
||||
|
||||
refactoring->activateEditor(m_targetFileName, targetPosition1);
|
||||
const int prefixLineCount = loc.prefix().count(QLatin1Char('\n'));
|
||||
refactoring->activateEditor(m_targetFileName, loc.line() + prefixLineCount,
|
||||
qMax(((int) loc.column()) - 1, 0));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -43,7 +43,16 @@ RefactoringChanges::RefactoringChanges()
|
||||
{}
|
||||
|
||||
RefactoringChanges::~RefactoringChanges()
|
||||
{}
|
||||
{
|
||||
if (!m_fileToOpen.isEmpty()) {
|
||||
BaseTextEditor *editor = editorForFile(m_fileToOpen, true);
|
||||
editor->gotoLine(m_lineToOpen, m_columnToOpen);
|
||||
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
editorManager->activateEditor(editor->editableInterface(),
|
||||
Core::EditorManager::ModeSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
BaseTextEditor *RefactoringChanges::editorForFile(const QString &fileName,
|
||||
bool openIfClosed)
|
||||
@@ -156,14 +165,11 @@ BaseTextEditor *RefactoringChanges::openEditor(const QString &fileName, int pos)
|
||||
return editor;
|
||||
}
|
||||
|
||||
BaseTextEditor *RefactoringChanges::activateEditor(const QString &fileName, int pos)
|
||||
void RefactoringChanges::activateEditor(const QString &fileName, int line, int column)
|
||||
{
|
||||
BaseTextEditor *editor = openEditor(fileName, pos);
|
||||
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
editorManager->activateEditor(editor->editableInterface(), Core::EditorManager::ModeSwitch);
|
||||
|
||||
return editor;
|
||||
m_fileToOpen = fileName;
|
||||
m_lineToOpen = line;
|
||||
m_columnToOpen = column;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -105,11 +105,12 @@ public:
|
||||
|
||||
BaseTextEditor *openEditor(const QString &fileName, int pos = -1);
|
||||
|
||||
/**
|
||||
* \param fileName the file to activate the editor for
|
||||
* \param pos, 0-based offset to put the cursor on, -1 means don't move
|
||||
/*!
|
||||
\param fileName the file to activate the editor for
|
||||
\param line the line to put the cursor on (1-based)
|
||||
\param column the column to put the cursor on (1-based)
|
||||
*/
|
||||
BaseTextEditor *activateEditor(const QString &fileName, int pos = -1);
|
||||
void activateEditor(const QString &fileName, int line, int column);
|
||||
|
||||
|
||||
private:
|
||||
@@ -121,6 +122,11 @@ private:
|
||||
virtual void fileChanged(const QString &fileName) = 0;
|
||||
|
||||
friend class RefactoringFile;
|
||||
|
||||
private:
|
||||
QString m_fileToOpen;
|
||||
int m_lineToOpen;
|
||||
int m_columnToOpen;
|
||||
};
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
Reference in New Issue
Block a user