aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r--src/plugins/texteditor/basehoverhandler.cpp2
-rw-r--r--src/plugins/texteditor/highlighter.cpp23
-rw-r--r--src/plugins/texteditor/highlightersettingspage.ui3
-rw-r--r--src/plugins/texteditor/texteditor.cpp7
-rw-r--r--src/plugins/texteditor/texteditor.h2
-rw-r--r--src/plugins/texteditor/texteditor.pro12
-rw-r--r--src/plugins/texteditor/texteditor_dependencies.pri18
7 files changed, 60 insertions, 7 deletions
diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp
index 72e35ba5bb3..92dae73d591 100644
--- a/src/plugins/texteditor/basehoverhandler.cpp
+++ b/src/plugins/texteditor/basehoverhandler.cpp
@@ -145,7 +145,7 @@ void BaseHoverHandler::decorateToolTip()
if (Qt::mightBeRichText(toolTip()))
setToolTip(toolTip().toHtmlEscaped());
- if (lastHelpItemIdentified().isValid()) {
+ if (lastHelpItemIdentified().isValid() && !lastHelpItemIdentified().isFuzzyMatch()) {
const QString &helpContents = lastHelpItemIdentified().extractContent(false);
if (!helpContents.isEmpty()) {
m_toolTip = toolTip().toHtmlEscaped();
diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp
index 4178dc7195f..5b60b885ab4 100644
--- a/src/plugins/texteditor/highlighter.cpp
+++ b/src/plugins/texteditor/highlighter.cpp
@@ -258,6 +258,16 @@ void Highlighter::handleShutdown()
delete highlightRepository();
}
+static bool isOpeningParenthesis(QChar c)
+{
+ return c == QLatin1Char('{') || c == QLatin1Char('[') || c == QLatin1Char('(');
+}
+
+static bool isClosingParenthesis(QChar c)
+{
+ return c == QLatin1Char('}') || c == QLatin1Char(']') || c == QLatin1Char(')');
+}
+
void Highlighter::highlightBlock(const QString &text)
{
if (!definition().isValid())
@@ -266,8 +276,21 @@ void Highlighter::highlightBlock(const QString &text)
KSyntaxHighlighting::State state = TextDocumentLayout::userData(block)->syntaxState();
state = highlightLine(text, state);
block = block.next();
+
+ Parentheses parentheses;
+ int pos = 0;
+ for (const QChar &c : text) {
+ if (isOpeningParenthesis(c))
+ parentheses.push_back(Parenthesis(Parenthesis::Opened, c, pos));
+ else if (isClosingParenthesis(c))
+ parentheses.push_back(Parenthesis(Parenthesis::Closed, c, pos));
+ pos++;
+ }
+ TextDocumentLayout::setParentheses(currentBlock(), parentheses);
+
if (block.isValid())
TextDocumentLayout::userData(block)->setSyntaxState(state);
+ formatSpaces(text);
}
void Highlighter::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format)
diff --git a/src/plugins/texteditor/highlightersettingspage.ui b/src/plugins/texteditor/highlightersettingspage.ui
index fcd4919b128..7b1e6c9e0da 100644
--- a/src/plugins/texteditor/highlightersettingspage.ui
+++ b/src/plugins/texteditor/highlightersettingspage.ui
@@ -127,6 +127,9 @@
</item>
<item>
<widget class="QPushButton" name="resetCache">
+ <property name="toolTip">
+ <string>Reset definitions remembered for files that can be associated with more than one highlighter definition.</string>
+ </property>
<property name="text">
<string>Reset Remembered Definitions</string>
</property>
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 36abfc01e29..3c4c8cd516e 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -8508,13 +8508,14 @@ BaseTextEditor *BaseTextEditor::currentTextEditor()
return qobject_cast<BaseTextEditor *>(EditorManager::currentEditor());
}
-BaseTextEditor *BaseTextEditor::textEditorForDocument(TextDocument *textDocument)
+QVector<BaseTextEditor *> BaseTextEditor::textEditorsForDocument(TextDocument *textDocument)
{
+ QVector<BaseTextEditor *> ret;
for (IEditor *editor : Core::DocumentModel::editorsForDocument(textDocument)) {
if (auto textEditor = qobject_cast<BaseTextEditor *>(editor))
- return textEditor;
+ ret << textEditor;
}
- return nullptr;
+ return ret;
}
TextEditorWidget *BaseTextEditor::editorWidget() const
diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h
index d792a1b12c7..3d079bf77f3 100644
--- a/src/plugins/texteditor/texteditor.h
+++ b/src/plugins/texteditor/texteditor.h
@@ -111,7 +111,7 @@ public:
virtual void finalizeInitialization() {}
static BaseTextEditor *currentTextEditor();
- static BaseTextEditor *textEditorForDocument(TextDocument *textDocument);
+ static QVector<BaseTextEditor *> textEditorsForDocument(TextDocument *textDocument);
TextEditorWidget *editorWidget() const;
TextDocument *textDocument() const;
diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro
index d5bf895ee47..29231afb82c 100644
--- a/src/plugins/texteditor/texteditor.pro
+++ b/src/plugins/texteditor/texteditor.pro
@@ -2,7 +2,19 @@ DEFINES += TEXTEDITOR_LIBRARY
QT += gui-private network printsupport xml
CONFIG += exceptions
CONFIG += include_source_dir # For the highlighter autotest.
+
+include(../../shared/syntax/syntax_shared.pri)
+isEmpty(KSYNTAXHIGHLIGHTING_LIB_DIR) | isEmpty(KSYNTAXHIGHLIGHTING_INCLUDE_DIR) {
+ QTC_LIB_DEPENDS += syntax-highlighting
+} else {
+ unix:!disable_external_rpath {
+ !macos: QMAKE_LFLAGS += -Wl,-z,origin
+ QMAKE_LFLAGS += -Wl,-rpath,$$shell_quote($${KSYNTAXHIGHLIGHTING_LIB_DIR})
+ }
+}
+
include(../../qtcreatorplugin.pri)
+
SOURCES += texteditorplugin.cpp \
plaintexteditorfactory.cpp \
textdocument.cpp \
diff --git a/src/plugins/texteditor/texteditor_dependencies.pri b/src/plugins/texteditor/texteditor_dependencies.pri
index c624e4cfb23..85ccb3ded7f 100644
--- a/src/plugins/texteditor/texteditor_dependencies.pri
+++ b/src/plugins/texteditor/texteditor_dependencies.pri
@@ -2,7 +2,21 @@ QTC_PLUGIN_NAME = TextEditor
QTC_LIB_DEPENDS += \
aggregation \
extensionsystem \
- utils \
- syntax-highlighting
+ utils
+
QTC_PLUGIN_DEPENDS += \
coreplugin
+
+# needed for plugins that depend on TextEditor plugin
+include(../../shared/syntax/syntax_shared.pri)
+!isEmpty(KSYNTAXHIGHLIGHTING_LIB_DIR):!isEmpty(KSYNTAXHIGHLIGHTING_INCLUDE_DIR) {
+ INCLUDEPATH *= $${KSYNTAXHIGHLIGHTING_INCLUDE_DIR}
+ LIBS *= -L$$KSYNTAXHIGHLIGHTING_LIB_DIR -lKF5SyntaxHighlighting
+
+ linux {
+ QMAKE_LFLAGS += -Wl,-z,origin
+ QMAKE_LFLAGS += -Wl,-rpath,$$shell_quote($${KSYNTAXHIGHLIGHTING_LIB_DIR})
+ }
+} else {
+ QTC_LIB_DEPENDS += syntax-highlighting
+}