Commit Graph

648 Commits

Author SHA1 Message Date
David Schulz
39a448c62e Editor: Simplify TextDocumentManipulator
The TextDocumentManipulatorInterface was introduced to decouple
modification operations from QTextDocument. But nowadays all tests and
production code usages are backed by a QTextDocument, so we can remove
this abstraction layer again. The first step is to merge the interface
and all manipulator implementations.

Change-Id: Idd1609df549d3b120dd516d5161af9aa8aa571ca
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2024-06-27 04:28:55 +00:00
Christian Kandeler
c3d28861da TextEditor: Add some logging for code folding
Change-Id: I95f6c1b370d458602d9d97e36b21d61c1d261e59
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-06-26 12:06:43 +00:00
hjk
8a6e1d6c06 TextEditor: Avoid some deprecation warnings
Change-Id: I05ceed344086f1cf75926f132422a1e0ae30cf08
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-06-11 05:47:42 +00:00
hjk
f64232f77b Fix some random deprecation warning
if QT_DEPRECATED_SINCE(6, 0)
    QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()")
    inline QPoint pos() const { return position().toPoint(); }
    ...

Change-Id: If885b26c8e5f4d68ca1c5c7e4ffc495b0701b210
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-06-06 07:17:26 +00:00
Eike Ziller
d29eebf9de Merge remote-tracking branch 'origin/13.0'
Change-Id: I51f8df79cf2b0f853e2951ed35b2a80369078411
2024-05-31 08:25:10 +02:00
David Schulz
f00394b371 TextEditor: avoid setting a null cursor on select all
Change-Id: If7ccdf1e1d4846b279305e30d3a990754f942128
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-05-30 11:43:43 +00:00
Tim Jenssen
4515fba526 Merge remote-tracking branch 'origin/qds/dev'
Conflicts: src/plugins/qmldesigner/CMakeLists.txt

Change-Id: I250c8e5284ddb0f335c440999b8920762419c89b
2024-05-28 19:06:18 +02:00
hjk
917523d7e3 Fix a few {QByteArray,QList}::count related deprecation warnings
Change-Id: I493e557a2ec976560c9e37312d8ae860490a2831
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-05-24 07:06:47 +00:00
Eike Ziller
e964a0e2a7 TextEditor: Move navigation history update from Widget to IEditor
Telling the EditorManager to update the navigation history only really
makes sense in the context of IEditor, not if the widget is used in some
other context.

For this reason the code in the text editor widget also had a check to
only add history in case the current editor's widget is the text editor
widget - which does not work in case of e.g. the Markdown editor or the
Compiler Explorer. Signaling the request for adding navigation points to
the IEditor gives these other editors that integrate text editor(s) a
chance to implement this too.

Change-Id: Id1bb3516519f48a3f4448ac226be21e52bb02b2b
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-05-17 06:52:04 +00:00
Eike Ziller
9f1c6e9c72 TextEditors: Do not add to history twice for Ctrl+Click navigation
When Ctrl+Clicking to follow symbols, the original location was added
twice to the history, once in the click handler, and once when the link
was opened in `TextEditorWidget::openLink`

Change-Id: I806165621d7ea229aa963b5b7d83c5327d8e7f14
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-05-17 06:51:52 +00:00
Tim Jenssen
310abd3b70 TextEditor: use modern approach to delete TextEditorWidgetPrivate
Try to tackle the crash at destruction:

https://the-qt-company-00.sentry.io/issues/5315538277
https://the-qt-company-00.sentry.io/issues/5312380342
https://the-qt-company-00.sentry.io/issues/5237253338

Pick-to: qds/4.5
Change-Id: Id4436bf5adc0c725f9b5538480619ed99428413f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2024-05-14 19:15:37 +00:00
Eike Ziller
dea0da7a8b Merge remote-tracking branch 'origin/13.0'
Conflicts:
	src/plugins/languageclient/languageclientutils.cpp

Change-Id: I8d1945f79d93cecee9b22f409bc5f2eefaf6a4cd
2024-04-26 10:59:07 +02:00
David Schulz
d717e7be04 TextEditor: fix backspace on block start
Amends ec88d279a8

Change-Id: I7d83b5ffa617f8d45acc6998ce674b1afcf3a31b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-04-24 14:20:12 +00:00
Tim Jenssen
ef0ee52bf9 Merge remote-tracking branch 'origin/qds/dev'
Conflicts:
	doc/qtcreator/src/overview/creator-only/creator-keyboard-shortcuts.qdoc
	doc/qtcreator/src/qtquick/qtquick-live-preview-devices.qdoc
	doc/qtcreator/src/qtquick/qtquick-profiler.qdoc
	src/plugins/qmlprojectmanager/qmlprojectmanager.qbs
	src/plugins/remotelinux/linuxdevicetester.cpp

Change-Id: I3683c1799df05209d05413383456b285a2daf96e
2024-04-23 16:05:55 +02:00
David Schulz
592d7f0c94 TextEditor: Fix calculating block highlight background color
Fixes: QTCREATORBUG-30649
Change-Id: I9a213ecdf4d58ed6531014c99bbdedac8ac9ef00
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-04-23 05:51:07 +00:00
David Schulz
ec88d279a8 TextEditor: Optimize unindent backspace behavior
Only remove more than one character when the cursor is inside the
indentation in the beginning of the line. In all other cases always only
remove one character.

Fixes: QTCREATORBUG-30725
Change-Id: I973101a95768cdd8b1a318972f53423eb72eb157
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-04-22 10:07:32 +00:00
Marcus Tillmanns
9019520d62 CompilerExplorer: Fix Undo/Redo actions
Change-Id: Ib3f55467764600d0b1e4ef25b53874a4d37a7ba7
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-04-18 09:31:40 +00:00
David Schulz
18a867aa23 Editor: use unique id without common part
Otherwise we also got override action warnings after opening a second
editor.

Change-Id: Id600eaa120e32399a941768ae5d5e35ab969be49
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-04-12 11:08:16 +00:00
David Schulz
41e581d0e1 Editor: fix assist actions
Amends 411100b037

Fixes: QTCREATORBUG-30673
Change-Id: Icc82b6f5526d229a13a7061cbc44904837c25f06
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2024-04-12 11:08:07 +00:00
David Schulz
ec3a5b5fd0 Editor: move setScriptable to context actions
The scriptable info is saved to the action registered for a specific context
so we need to add this info to the action builder in the text editor that has the correct context.

Also remove all action builder constructs for the global context that have been registered before
in order to silence the add override action warning.

Change-Id: I631d71ba5eb8e975190713b33827926e868da295
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-04-11 12:34:40 +00:00
David Schulz
411100b037 TextEditor: remove text editor action handler
Give each editor a context and register editor actions individually for
that context. This removes the need to tell the action handler the
current editor. Additionally all actions are now available in editor
widgets outside of the EditorManager.

Change-Id: I0109866b180889762f8bd8aa07874d8d7c55bfa6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-04-09 10:52:26 +00:00
David Schulz
d4e775ebc6 TextEditor: handle syntax highlight in batches
Use an elapsed timer in the syntax highlighter to periodically return
from the highlight and push a continue highlight to the end of the event
loop.
This allows the user to interact with the editor in between those
batches. If the user modifies the document in between highlighting
batches, the area that still needs a rehighlight is increased if needed.

This also reverts 62ea85ee6a and the
related changes.

Task-number: QTCREATORBUG-28727
Change-Id: I7c394dbdff658330bb72f3b68b9928980947db75
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-03-25 08:57:37 +00:00
Christian Kandeler
3f457c158f TextEditor: Add type hierarchy infrastructure
We want to support more than one back-end in the future.

Task-number: QTCREATORBUG-28116
Change-Id: I72020c94b36072a297e13f44130e5e2482922cd4
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-03-12 13:22:51 +00:00
David Schulz
3691053760 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 <marcus.tillmanns@qt.io>
2024-03-05 11:48:49 +00:00
Artem Sokolovskii
38ea622416 TextEditor: Fix jump to a search result to a folded block
Change-Id: Id9963bdf2a02930911753af046443e9b657bc9b9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-29 13:32:49 +00:00
Artem Sokolovskii
49ab0c4109 TextEditor: Fix jump to search result
Change-Id: Ie570936b0b96290d95999b8b501c12610ebfc9a8
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-29 09:48:42 +00:00
Artem Sokolovskii
95a5f01096 TextEditor: Fix folding for async syntax highlighter
- Made restoreState, ensureBlockIsUnfolded, fold, unfold and unfoldAll
functions to be called only after highlighting is done
- Improved management of foldValidator in async case
- Removed optimizations in cpphighlighter and glshighlighter.
The highlighters are async now and optimization is not necessary.
In these optimizations in the function highlightBlock the highlighting
changes not only for currentBlock but and for several next. Which is
contradict with the function name.

Change-Id: Ib413e6b982eb39d52f36c3066ff0fa8c28fbe231
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-28 11:53:02 +00:00
David Schulz
8feb31b2ac TextEditor: bound increase and decreaseFontZoom to a 10% grid
This allows to get back to a 100% font zoom with the keyboard shortcuts
by zooming to an odd zoom factor by other means.

Change-Id: Ie90853367b17c207e9c47fc108b8d6f451e0f838
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-02-23 12:01:29 +00:00
David Schulz
a18522334c TextEditor: fix multi text cursor unindent via backspace
Change-Id: Iec2e9251b977ccbd7433009ac3e706a9327c704c
(cherry picked from commit 971bcb1a5a)
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-22 06:32:39 +00:00
Jarek Kobus
acb449bb2b TextEditor: Fix a leak of CompletionAssistProvider
The c'tor of QmlJSEditorFactory allocates QmlJSCompletionAssistProvider
and sets it via setCompletionAssistProvider.
The QbsEditorFactory subclass allocates QbsCompletionAssistProvider
and overrides the previous one via setCompletionAssistProvider.
So, the old one was leaking.

Use std::unique_ptr to ensure the ownership.

Change-Id: I6fb7da2b97c50919e422482c858d3503403b788d
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-13 08:26:23 +00:00
Jarek Kobus
f2dbd28165 CircularClipboard: Replace QSharedPointer with std::shared_ptr
According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews
QSharedPointer impl is poor and it's going to be removed from Qt 7.

Change-Id: I3ec37f65318fe1e41f6daf98238a543f85293c48
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-05 08:54:31 +00:00
hjk
bc15dcd8fe TextEditor: Move access to smaller settings chunks
Change-Id: Id827edbd19dde54b66cb4349d9c832bc23110adc
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-02-01 13:50:53 +00:00
David Schulz
f4b3b85fee TextEditor: Merge Base- and ThreadedSyntaxHighlighterRunner
Change-Id: I38ad01a895eabba99b2e554f3ae9bef85f32bb3b
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2024-01-31 10:20:56 +00:00
Eike Ziller
e1da48bf86 CodecSelector: Hide dialog class behind function
It isn't necessary to export the class (which would then best have a d-
pointer etc). Just provide a function that asks the user for a codec and
returns their decision. This makes the whole dialog an implementation
detail.

Change-Id: I7d574561cbe7f079a6d383ba65ba70f6868bbf05
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-24 10:00:18 +00:00
David Schulz
15a1fd6afc TextEditor: reduce complexity of bookmark requests
Since the book mark support is nowadays part of the text editor plugin
we can directly access the bookmark manager from within the editor
without the indirection over the TextEditorPluginPrivate.

Change-Id: I5c04679d6583c06d615d489d3891431adcb64834
Reviewed-by: hjk <hjk@qt.io>
2024-01-19 12:45:16 +00:00
Mathias Hasselmann
2e353aa1b2 TextEditor: Give access to m_toolBarWidget
The TextEditor doesn't export its actual toolbar via IEditor::toolBar(),
but an internal container widget. This forces other editors that want to
reuse TextEditorWidget to poke into internal details of TextEditorWidget
if they want to provide the full toolbar including line number button.

By giving access to m_toolBarWidget, other editors like the Markdown
editor can show the full toolbar including line numbers without risking
to break, if TextEditorWidget should refactor its toolbar container.

Task-number: QTCREATORBUG-30166
Change-Id: Ic54f21be1897f00801c6a3cfe29c89131d61e3a5
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-11 11:34:05 +00:00
Eike Ziller
cf63b1884e Merge remote-tracking branch 'origin/12.0'
Conflicts:
	src/libs/utils/treemodel.cpp
	src/libs/utils/treemodel.h

Change-Id: I9c5e8ef77905745c201cfc647218c9e747d268d6
2024-01-08 14:56:54 +01:00
David Schulz
419eae839a TextEditor: improve line column button tooltip
Automatically hide the tooltip of the line column button in the editor
toolbar when the cursor leaves the widget.

Change-Id: Ia17f40029d0821584c8a804b44431a5d7e639066
Reviewed-by: hjk <hjk@qt.io>
2024-01-08 12:37:21 +00:00
Mathias Hasselmann
a213ce3875 TextEditor: Repair insertExtraToolBarWidget()
New extra widgets for the right side were wrongly inserted between the
buttons for line-ending text-encoding.

Task-number: QTCREATORBUG-30166
Change-Id: I0f55c44344f9586e6aa97da20f5e25c28adf964c
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-08 10:21:13 +00:00
Marcus Tillmanns
7cc970ce5a TextEditor: Sort extraSelections
When applied to the QPlainTextEdit, the first selection for a range wins.
We want "OtherSelection" which is used for links to win, so we "sort"
it to the beginning of the final list.

Change-Id: Idf84c92ad5bd12d9f6ad6381f7e556e51ee459a9
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-14 08:45:12 +00:00
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