Commit Graph

608 Commits

Author SHA1 Message Date
Artem Sokolovskii
e396f84d10 SyntaxHighlighter: Move generic highlighter to separate thread
Adds a full copy of KSyntaxHighlighting::Repository class
to the Highlighter class, enabling the relocation of the
Highlighter class to a separate thread. This adjustment ensures
that all Definitions come from the copy of the repository, making
them immutable from external code.

The "reload Definition" function stays supported, as triggering
it results in the recreation of the highlighter for the document,
thereby reconstructing the Repository class.

Change-Id: Id7a4d865228c7e7e20e4770601a3fde55b8a6513
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-12 13:03:59 +00:00
hjk
016936a450 Clean up some lambdas
Change-Id: Id947c0935b1aa4579e1c64d3e510db41103fbe27
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-12-12 10:55:32 +00:00
Artem Sokolovskii
62ea85ee6a SyntaxHighlighter: Move SyntaxHighlighter to separate thread
This change involves the relocation of SyntaxHighlighter processing
to another thread. The core idea is to create a duplicate of the
original TextDocument using SyntaxHighlighterRunnerPrivate::cloneDocument.
A new SyntaxHighlighter is then instantiated by SyntaxHighLighterCreator
for the cloned document. The entire SyntaxHighLighterCreator class is
moved to a new thread, where it performs highlighting on the cloned
document. Upon completion of the highlighting process, the resultsReady
signal is emitted, and the updated highlighting data is applied to the
original document.

This shift of SyntaxHighlighter to another thread enhances the user
experience by preventing UI slowdowns during the highlighting process.

- Introduction of BaseSyntaxHighlighterRunner as an interface class for
future *SyntaxHighlighterRunner.
- Inclusion of DirectSyntaxHighlighterRunner class for performing
highlighting in the main thread, suitable for syntax highlighters
that cannot be moved to another thread.
- Introduction of ThreadedSyntaxHighlighterRunner class for highlighting
in a separate thread, preventing UI blocking during the process.
- Addition of Result data to the SyntaxHighlighter class to facilitate
data exchange between threads.

Task-number: QTCREATORBUG-28727
Change-Id: I4b6a38d15f5ec9b8828055d38d2a0c6f21a657b4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-11 09:55:02 +00:00
Marcus Tillmanns
4153520fb6 TextEditor: Allow opening links without filename
... in editors displaying a document without a filename.

Change-Id: I857018e2532b406a37983d8fd77e52daa31ae70d
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-04 08:33:11 +00:00
Eike Ziller
c75a3bcd5d Merge remote-tracking branch 'origin/12.0'
Change-Id: I0ee9c73d7a7e12f98f88b161c35d00ada069cc9d
2023-11-21 14:46:01 +01:00
Artem Sokolovskii
b26c43f133 SyntaxHighlighter: Move static functions to other namespace
- Created HighlighterHelper namespace and static functions
were moved there from the highlighter class

Change-Id: Ib93785a3819317d7c1d5cc480652d4635cb9339b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-11-20 16:04:59 +00:00
Artem Sokolovskii
4bfc3476f4 SyntaxHighlighter: Move highlighter creating to TextDocument
Added setSyntaxHighlighterCreator function to TextDocument
which allows the creation of highlighters inside TextDocument.

Change-Id: I454f800c878c48a154dad5abd68b7a4f9ceb378a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-11-20 14:52:20 +00:00
David Schulz
d81d41032a TextEditor: do not collapse doc comments in the beginning of a file
The auto fold license header functionality also automatically folds
documentation comments. Automatically collapsing documentation comments
is never correct in the first place so just skip the fold when encounter
a documentation marker in the first comment.

Fixes: QTCREATORBUG-29900
Change-Id: If0dd7842804f3ff0bcd725b54413e9568d5b5ab3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-11-20 13:39:30 +00:00
Eike Ziller
583a9dcea1 Add Line/Column indicator to Markdown editor
And make the LineColumnButton independent of IEditor for that (since the
IEditor for the Markdown editor is not a TextEditor.

Change-Id: I52d378ec46d86b1c7928d18f7d39f9726bb6ad23
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-17 08:15:43 +00:00
Tim Jenssen
9f1d23df00 Merge remote-tracking branch 'origin/qds/dev'
Change-Id: Ic852bc9977d0292fb6cd93a319f4bfdebb22a1b0
2023-11-16 17:17:46 +01:00
Tim Jenssen
39d1dae0d3 Merge remote-tracking branch 'origin/12.0' into qds/dev
Change-Id: Ic6e557806a3209e2c6d983d3c3fcfad66f6e3066
2023-11-16 15:56:06 +01:00
hjk
d739a14950 TextEditor: Delay-construct ClipboardAssistProvider
Change-Id: I34d1e2e8f99e55e574e148bef700811fb33d9449
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-16 12:15:45 +00:00
Eike Ziller
0269626a17 Make LineColumnButton re-usable
Change-Id: I34e755018eef41e7e7cf254ccba72a1ec5a1c5ff
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-15 09:30:17 +00:00
Eike Ziller
206000a3d6 Fix state of LineColumButton after clicking
When using the `pressed` signal, the button stays in the "pressed" state
forever afterwards. Using the `clicked` signal behaves correctly, so use
that instead.

Change-Id: I646c93f1db3b1176630f1cfa718aba01d0aaf252
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-14 13:38:04 +00:00
The Qt Project
841d9d739e Merge "Merge remote-tracking branch 'origin/12.0' into qds/dev" into qds/dev 2023-11-09 09:24:26 +00:00
Thomas Hartmann
070022e9e2 TextEditor: Allow to programmatically highlight a block by cursor
This can be used in QmlDesigner to highlight the currently selected
QML object.

Change-Id: I9907d54f767c7d034739d4111a46cd994c961426
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2023-11-09 08:53:25 +00:00
Eike Ziller
363d2d161c Merge remote-tracking branch 'origin/12.0'
Change-Id: I35cb28b759fb200c45a1496299584132336fcd1c
2023-11-08 10:07:29 +01:00
David Schulz
4a081cb386 TextEditor: remove texteditor_p.h
There is no need to have an extra file for one struct that is only used
inside texteditor.cpp

Change-Id: Iee8f7ce5e0d19da7b444660d81c350eb10b501ef
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 15:24:57 +00:00
Eike Ziller
df80454d26 Merge remote-tracking branch 'origin/12.0'
Change-Id: I04104ef638b28d99da11b9b7a22f31f8d0ddf460
2023-10-24 13:05:55 +02:00
David Schulz
2e93051aaf TextEditor: improve sort selected lines
Try to get a sensible scope when there is no selection when sorting
lines.

Use the indent level of the current block and select all blocks that are
not empty with the same indent level around that block before sorting
the lines.

Change-Id: I68cbd95f95a0cc4425a0339b992225c3946a6858
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-10-24 07:38:38 +00:00
David Schulz
6f4b9639ce TextEditor: highlight selected text
Change-Id: Ib46908decef51d478f6954a116108c48e4a07ed3
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-10-23 07:33:45 +00:00
Leena Miettinen
61088bba69 Fix UI text capitalization, punctuation, and phrasing
Change-Id: I41951660a464601063e5cedd417db2cb7cd37e44
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-20 14:55:38 +00:00
David Schulz
5f45c36b6f TextEditor: do not scroll to cursor postion on select all
Since Qt 6.5.1 QPlainTextEdit::selectAll emits correctly
cursorPositionChanged on selectAll which calls some multitextcursor
update code on our side. Avoid setting the cursor back to the
QPlainTextEdit in this update code by setting the expected
MultiTextCursor before calling selectAll.

Fixes: QTCREATORBUG-29763
Change-Id: I77f05ac40a9dd126efcd72089a699c908c68da21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-20 10:47:34 +00:00
Eike Ziller
a253a2aa95 Tr: Fix lupdate issues
Add missing `Tr::` and use some fully qualified namespaces where lupdate
fails to resolve it correctly.

Change-Id: Ied4ac7bf0438a9080d0b76a9a1f5033dbc94a163
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-18 11:21:52 +00:00
Marcus Tillmanns
fdeff13ca3 TextEditor: Don't export KSyntaxHighlighting
Change-Id: I84fa8c758af412d8847391a628deac60279b9448
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-10-17 13:25:50 +00:00
Marcus Tillmanns
d8a75d48a3 TextEditor: Add selecting highlighter by name
Change-Id: I5c706dd151173bf08c5fbd4dacbf6e5d6416b87b
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-10-17 08:47:45 +00:00
David Schulz
483a340e73 TextEditor: speed up searching in huge documents
Avoid creating QTextCursors for checking whether a search result is
inside the find scope. QTextCursor::setPosition seems to layout the
block the cursor is positioned at, which is not for free and not needed
to verify whether a search result is inside the find scope.

Change-Id: Ia1658fbbaa89a61f862e0b97eaa5b059972e2311
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-13 11:37:29 +00:00
David Schulz
eda0dbd8dd TextEditor: modernize highlighting search results
Change-Id: I365a09dfd9d371119044da5567a1adb397f3ac93
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-10-12 07:58:49 +00:00
David Schulz
80633a59aa LanguageClient: support additional goto targets in symbol support
Allow to follow to the symbol definition as well as to the type
definition for the symbol under the cursor position.

Change-Id: I8ff50b33a1e739f81b0832b1b28ffc525e1f7177
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-09-29 09:10:14 +00:00
David Schulz
7c28cc0565 Editor: transform the encoding label into button
Like for the line number label: Having a button instead of a labal makes
it more obvious that there is an action triggered when clicking the
label.

Change-Id: Ied15c05658c0b0b7df75cbcf1704808e94f6985d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-09-22 09:00:24 +00:00
David Schulz
0a323274d4 Editor: transform the line column label into button
Having a button instead of a labal makes it more obvious that there is
an action triggered when clicking the label.

Also fix the flickering introduced by
f0bb7e8bfa by saving the maximum width of
the sizeHint. Since the width can get big if we have a selection we do
not save the size in that case to avoid blocking the width when the
selection is removed again.

Change-Id: If8210ecbabb8c6449c4f88652fbed99f8526057d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-09-22 08:33:36 +00:00
David Schulz
9a0f61b7e2 TextEditor: reduce size of line ending chooser
Change-Id: I3be0890ee78e2e3159e1494f8b5e972e04f11f67
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-09-19 08:58:41 +00:00
Christian Kandeler
18372ca553 TextEditor: Do not make one-letter doxygen commands end a rewrap region
In 8e118e9d5e, we stopped re-wrapping in
comments when a doxygen/qdoc command appeared at the start of the line.
However, there are also "inline" commands such as \l and \c that can by
chance appear on the start of a line and should not stop rewrapping.
Since we are still quite reluctant to enumerate and categorize the
countless doxygen/qdoc commands, let's just ignore all one-letter
commands for rewrapping purposes.
(Yes, this is another hacky heuristic.)

Fixes: QTCREATORBUG-28761
Change-Id: I40d77706851ec24504d6fd8795906dd55249661d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-18 09:18:02 +00:00
David Schulz
aab39532f3 TextEditor: Collect the comment position setting from highlighter
Change-Id: I802b9e263a3515fe340459329a8c8d8f309cfa0e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-09-15 10:50:44 +00:00
Xavier BESSON
5cfe69ea1e Add possibility to comment selection after the white spaces
Fixes: QTCREATORBUG-29410
Change-Id: I736378e0b5fb542a6c1032a47adfb251b50ce2ef
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-09-14 06:59:00 +00:00
David Schulz
28742774fe TextEditor: add rename symbol option to editor context menu
... if the action handler supports the rename option.

Change-Id: Ic1bad19a490aaccc8e96afd1f74741596bf6efc3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-08-28 07:52:52 +00:00
David Schulz
b128c585d9 TextEditor: render suggestion with the tab width of the editor
Fixes: QTCREATORBUG-29483
Change-Id: Id8da019130055ce40bd639d038eb1e74d9787884
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-08-10 13:37:33 +00:00
Christian Kandeler
099fe7d5d1 CppEditor: Let users fold/unfold all comment blocks
Fixes: QTCREATORBUG-2449
Change-Id: Ib090f1bb0d0866f14ddb6dfb10bf2ff2563585e0
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-08-08 08:52:55 +00:00
David Schulz
f0bb7e8bfa Editor: modernize line column label
This change contains various adjustments to the line column label:
 - Display the number of selected characters
 - Show the number of cursors instead of the position when multiple text
cursors are present in the current editor
 - show detailed information for each cursor in the line column tooltip

Fixes: QTCREATORBUG-29381
Change-Id: Ib4f36b290797f1d84f268deeb9556e78ae921c37
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2023-07-07 11:23:49 +00:00
David Schulz
b721d98476 Editor: optimize annotation cache cleanup
Looking up the last visible block is not for free since it calculates
the bounding rects for all blocks between the first and last visible
block. Avoid one calculation by postponing the annotation cleanup after
the paint event and only if we reach a certain amount of cached entries.

Change-Id: Ibfab49301f82237e16d5a69ce1531539907e7ed8
Reviewed-by: hjk <hjk@qt.io>
2023-07-04 06:41:09 +00:00
Eike Ziller
26e96bfad8 Merge remote-tracking branch 'origin/11.0'
Conflicts:
	src/plugins/debugger/debuggeritemmanager.cpp

Change-Id: I9d99d13feff9315f52eacbd84857c63cb69bf804
2023-07-03 10:24:09 +02:00
David Schulz
a207943f59 Editor: fix visual glitch after disabling overwrite mode
Change-Id: Ied85cf298a12a29cf448e6dec6c81f6a0a2dc4b7
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-06-28 12:35:35 +00:00
Christian Kandeler
cf6bd7e012 Fix occurrences of the contains/insert anti-pattern
Introduce and make use of Utils::insert() for QSet with a return value
that indicates whether insertion actually happened.

Change-Id: I655e4bc3553b74fea5ae8956205e4d8070118d63
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-06-23 09:51:54 +00:00
Eike Ziller
6c601b8cd4 Merge remote-tracking branch 'origin/11.0'
Change-Id: I8d1c9720a868da02b3157a48954eb4e262539c84
2023-06-15 09:48:58 +02:00
David Schulz
827d6e66f8 Editor: only paint the preedit cursor
Task-number: QTCREATORBUG-29134
Change-Id: Ia44b0c8ddc88da7b64527fea806139726d57243a
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-06-14 10:05:16 +00:00
Eike Ziller
e7870f736d Merge remote-tracking branch 'origin/11.0'
Conflicts:
	src/plugins/clangformat/clangformatutils.cpp

Change-Id: Ide285cc25fca9101843ab9dca01c5a33644aca7f
2023-06-14 08:43:08 +02:00
David Schulz
37433c1897 Editor: do not set the viewport margins if they have not changed
Change-Id: I01adabc52e47e8a47aff0f5dc2b580066e51307c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-06-14 04:58:49 +00:00
David Schulz
c547c8615f TextEditor: optimize setting refactor markers
emitting requestBlockUpdate is not for free so limitting it to blocks
that have changed improve the performance notable for documents with a
lot of refactoring markers.

Change-Id: Ie288a367d1d1d6a9f4359e37ff8486a1dfe36752
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-06-13 11:52:00 +00:00
David Schulz
4481686909 TextEditor: improve performance of painting indent depth
Avoid asking the indenter for the visual indent depth since some
implementations are not cheap and might even cause file io. Fall back to
the default detection.

Change-Id: Ic85d134fc29a0599768ac05c306b8593e83db327
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2023-06-13 09:05:21 +00:00
Eike Ziller
375db16ac4 Merge remote-tracking branch 'origin/11.0'
Change-Id: I87b22a73427cf9fc1b96075dc0db769ed3d3621c
2023-06-09 11:24:29 +02:00