Use 1-based locations.

This commit is contained in:
Roberto Raggi
2010-07-29 14:59:38 +02:00
parent 2b53ca3218
commit d3761d10e2
3 changed files with 22 additions and 18 deletions

View File

@@ -158,17 +158,20 @@ QStringList RefactoringChanges::apply()
Core::EditorManager *editorManager = Core::EditorManager::instance();
BaseTextEditor *editor = editorForFile(m_fileNameToShow);
editorManager->activateEditor(editor->editableInterface());
if (m_lineToShow != -1)
editor->gotoLine(m_lineToShow + 1, m_columnToShow);
if (m_lineToShow != 0) {
editor->gotoLine(m_lineToShow, qMax(0, int(m_columnToShow) - 1));
}
}
return changed.toList();
}
int RefactoringChanges::positionInFile(const QString &fileName, int line, int column) const
int RefactoringChanges::positionInFile(const QString &fileName, unsigned line, unsigned column) const
{
if (BaseTextEditor *editor = editorForFile(fileName, true)) {
return editor->document()->findBlockByNumber(line).position() + column;
Q_ASSERT(line != 0);
Q_ASSERT(column != 0);
return editor->document()->findBlockByNumber(line - 1).position() + column - 1;
} else {
return -1;
}
@@ -205,12 +208,7 @@ BaseTextEditor *RefactoringChanges::editorForNewFile(const QString &fileName)
return editorForFile(fileName, true);
}
/**
* \param fileName the file to open
* \param line the line to focus on, 0-based
* \param column the column to focus on, 0-based
*/
void RefactoringChanges::openEditor(const QString &fileName, int line, int column)
void RefactoringChanges::openEditor(const QString &fileName, unsigned line, unsigned column)
{
m_fileNameToShow = fileName;
m_lineToShow = line;