LanguageClient: use json editor in language client settings

Change-Id: Ib2b8dae730a701d71ae39a4eaf401f5feab7f921
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-08-24 09:29:16 +02:00
parent 201f5291eb
commit 4451da7037

View File

@@ -1030,9 +1030,16 @@ TextEditor::BaseTextEditor *jsonEditor()
{ {
using namespace TextEditor; using namespace TextEditor;
using namespace Utils::Text; using namespace Utils::Text;
BaseTextEditor *editor = PlainTextEditorFactory::createPlainTextEditor(); BaseTextEditor *textEditor = nullptr;
TextDocument *document = editor->textDocument(); for (Core::IEditorFactory *factory : Core::IEditorFactory::preferredEditorFactories("foo.json")) {
TextEditorWidget *widget = editor->editorWidget(); Core::IEditor *editor = factory->createEditor();
if (textEditor = qobject_cast<BaseTextEditor *>(editor); textEditor)
break;
delete editor;
}
QTC_ASSERT(textEditor, textEditor = PlainTextEditorFactory::createPlainTextEditor());
TextDocument *document = textEditor->textDocument();
TextEditorWidget *widget = textEditor->editorWidget();
widget->configureGenericHighlighter(Utils::mimeTypeForName("application/json")); widget->configureGenericHighlighter(Utils::mimeTypeForName("application/json"));
widget->setLineNumbersVisible(false); widget->setLineNumbersVisible(false);
widget->setMarksVisible(false); widget->setMarksVisible(false);
@@ -1063,7 +1070,7 @@ TextEditor::BaseTextEditor *jsonEditor()
mark->setIcon(Utils::Icons::CODEMODEL_ERROR.icon()); mark->setIcon(Utils::Icons::CODEMODEL_ERROR.icon());
document->addMark(mark); document->addMark(mark);
}); });
return editor; return textEditor;
} }
} // namespace LanguageClient } // namespace LanguageClient