From 38ea6224164887024c96f5f5b6f655fe250ad497 Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Thu, 29 Feb 2024 12:35:57 +0100 Subject: TextEditor: Fix jump to a search result to a folded block Change-Id: Id9963bdf2a02930911753af046443e9b657bc9b9 Reviewed-by: Reviewed-by: David Schulz --- src/plugins/texteditor/texteditor.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins/texteditor') diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index baf027d124d..054e65193f4 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3552,6 +3552,7 @@ void TextEditorWidget::restoreState(const QByteArray &state) QTC_ASSERT(documentLayout, return); documentLayout->requestUpdate(); documentLayout->emitDocumentSizeChanged(); + d->updateCursorPosition(); } }; if (!singleShotAfterHighlightingDone(foldingRestore)) @@ -6696,6 +6697,9 @@ void TextEditorWidget::ensureBlockIsUnfolded(QTextBlock block) void TextEditorWidgetPrivate::toggleBlockVisible(const QTextBlock &block) { + if (q->singleShotAfterHighlightingDone([this, block] { toggleBlockVisible(block); })) + return; + auto documentLayout = qobject_cast(q->document()->documentLayout()); QTC_ASSERT(documentLayout, return); -- cgit v1.2.3 From 02bac284885be6760102f92ba3eadb0bd9354d24 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 29 Feb 2024 14:34:26 +0100 Subject: TextEditor: add mime type for device tree source files Fixes: QTCREATORBUG-19029 Change-Id: I1959681cb7e0f9466cea3344836d7029a98b4548 Reviewed-by: Eike Ziller --- src/plugins/texteditor/TextEditor.json.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/plugins/texteditor') diff --git a/src/plugins/texteditor/TextEditor.json.in b/src/plugins/texteditor/TextEditor.json.in index 5fbf3e3067b..447d9c91c67 100644 --- a/src/plugins/texteditor/TextEditor.json.in +++ b/src/plugins/texteditor/TextEditor.json.in @@ -15,5 +15,15 @@ "Category" : "Core", "Description" : "Text editor framework and the implementation of the basic text editor.", "Url" : "http://www.qt.io", - ${IDE_PLUGIN_DEPENDENCIES} + ${IDE_PLUGIN_DEPENDENCIES}, + "Mimetypes" : [ + "", + "", + " ", + " Device tree source files", + " ", + " ", + " ", + "" + ] } -- cgit v1.2.3 From 369105376008101ef710130bf17ebda84d24cbb7 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 5 Mar 2024 09:24:42 +0100 Subject: TextEditor: fix finding whole words '_' was handled as a word separator, in contrast the global search did not. So the user received different results when using find toolbar or the advanced search while searching with the same option and pattern. Fixes: QTCREATORBUG-10276 Change-Id: Ie07303fbaa35475bb98bdb813358169474c3ba1d Reviewed-by: Marcus Tillmanns --- src/plugins/texteditor/texteditor.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/plugins/texteditor') diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 054e65193f4..3256ee91b79 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -4154,10 +4154,17 @@ void TextEditorWidgetPrivate::highlightSearchResults(const QTextBlock &block, co l = match.capturedLength(); if (l == 0) break; - if ((m_findFlags & FindWholeWords) - && ((idx && text.at(idx-1).isLetterOrNumber()) - || (idx + l < text.length() && text.at(idx + l).isLetterOrNumber()))) - continue; + if (m_findFlags & FindWholeWords) { + auto posAtWordSeparator = [](const QString &text, int idx) { + if (idx < 0 || idx >= text.length()) + return false; + const QChar c = text.at(idx); + return !c.isLetterOrNumber() && c != QLatin1Char('_'); + }; + if (!posAtWordSeparator(text, idx - 1) || !posAtWordSeparator(text, idx + l)) + continue; + } + const int start = blockPosition + idx; const int end = start + l; -- cgit v1.2.3