forked from qt-creator/qt-creator
ProjectExplorer: filepathify actualTabSettings
Change-Id: I4b08b96d56bfeed0348d82bb96ff70d5f8ad583b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -246,8 +246,7 @@ void CppRefactoringChangesData::indentSelection(const QTextCursor &selection,
|
|||||||
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
|
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
|
||||||
textDocument->indenter()->indent(selection, QChar::Null, textDocument->tabSettings());
|
textDocument->indenter()->indent(selection, QChar::Null, textDocument->tabSettings());
|
||||||
} else {
|
} else {
|
||||||
const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath.toString(),
|
const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath, textDocument);
|
||||||
textDocument);
|
|
||||||
auto indenter = createIndenter(filePath, selection.document());
|
auto indenter = createIndenter(filePath, selection.document());
|
||||||
indenter->indent(selection, QChar::Null, tabSettings);
|
indenter->indent(selection, QChar::Null, tabSettings);
|
||||||
}
|
}
|
||||||
@@ -260,8 +259,7 @@ void CppRefactoringChangesData::reindentSelection(const QTextCursor &selection,
|
|||||||
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
|
if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat
|
||||||
textDocument->indenter()->reindent(selection, textDocument->tabSettings());
|
textDocument->indenter()->reindent(selection, textDocument->tabSettings());
|
||||||
} else {
|
} else {
|
||||||
const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath.toString(),
|
const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath, textDocument);
|
||||||
textDocument);
|
|
||||||
auto indenter = createIndenter(filePath, selection.document());
|
auto indenter = createIndenter(filePath, selection.document());
|
||||||
indenter->reindent(selection, tabSettings);
|
indenter->reindent(selection, tabSettings);
|
||||||
}
|
}
|
||||||
|
@@ -407,12 +407,12 @@ void EditorConfiguration::slotAboutToRemoveProject(Project *project)
|
|||||||
deconfigureEditor(editor);
|
deconfigureEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabSettings actualTabSettings(const QString &fileName,
|
TabSettings actualTabSettings(const Utils::FilePath &file,
|
||||||
const TextDocument *baseTextdocument)
|
const TextDocument *baseTextdocument)
|
||||||
{
|
{
|
||||||
if (baseTextdocument)
|
if (baseTextdocument)
|
||||||
return baseTextdocument->tabSettings();
|
return baseTextdocument->tabSettings();
|
||||||
if (Project *project = SessionManager::projectForFile(Utils::FilePath::fromString(fileName)))
|
if (Project *project = SessionManager::projectForFile(file))
|
||||||
return project->editorConfiguration()->codeStyle()->tabSettings();
|
return project->editorConfiguration()->codeStyle()->tabSettings();
|
||||||
return TextEditorSettings::codeStyle()->tabSettings();
|
return TextEditorSettings::codeStyle()->tabSettings();
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,9 @@ class StorageSettings;
|
|||||||
class BehaviorSettings;
|
class BehaviorSettings;
|
||||||
class ExtraEncodingSettings;
|
class ExtraEncodingSettings;
|
||||||
class MarginSettings;
|
class MarginSettings;
|
||||||
}
|
} // namespace TextEditor
|
||||||
|
|
||||||
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -118,6 +120,6 @@ private:
|
|||||||
// the file belongs to and return the project settings. If the file doesn't belong to any
|
// the file belongs to and return the project settings. If the file doesn't belong to any
|
||||||
// project return the global settings.
|
// project return the global settings.
|
||||||
PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings(
|
PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings(
|
||||||
const QString &fileName, const TextEditor::TextDocument *baseTextDocument);
|
const Utils::FilePath &file, const TextEditor::TextDocument *baseTextDocument);
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -57,7 +57,7 @@ public:
|
|||||||
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
|
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
|
||||||
|
|
||||||
const TextEditor::TabSettings &tabSettings =
|
const TextEditor::TabSettings &tabSettings =
|
||||||
ProjectExplorer::actualTabSettings(filePath.toString(), textDocument);
|
ProjectExplorer::actualTabSettings(filePath, textDocument);
|
||||||
CreatorCodeFormatter codeFormatter(tabSettings);
|
CreatorCodeFormatter codeFormatter(tabSettings);
|
||||||
codeFormatter.updateStateUntil(block);
|
codeFormatter.updateStateUntil(block);
|
||||||
do {
|
do {
|
||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
const TextEditor::TextDocument *textDocument) const override
|
const TextEditor::TextDocument *textDocument) const override
|
||||||
{
|
{
|
||||||
const TextEditor::TabSettings &tabSettings =
|
const TextEditor::TabSettings &tabSettings =
|
||||||
ProjectExplorer::actualTabSettings(filePath.toString(), textDocument);
|
ProjectExplorer::actualTabSettings(filePath, textDocument);
|
||||||
|
|
||||||
QmlJSEditor::Internal::Indenter indenter(selection.document());
|
QmlJSEditor::Internal::Indenter indenter(selection.document());
|
||||||
indenter.reindent(selection, tabSettings);
|
indenter.reindent(selection, tabSettings);
|
||||||
|
Reference in New Issue
Block a user