Commit Graph

391 Commits

Author SHA1 Message Date
David Schulz
c00330f905 Editor: multi cursor support
Adding a way to create multiple cursors that can insert/remove text at
arbitrary positions in the document. Adding cursors is done by pressing
alt + up/down or by clicking into the editor while holding the alt key.

Fixes: QTCREATORBUG-16013
Change-Id: I495d27d95a3d277220946616ef30efc241da0120
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-27 10:56:54 +00:00
David Schulz
421e06393f TextEditor: update matching parenthesis in the editor
... after updating the parenthesis in the layout

Task-number: QTCREATORBUG-26183
Change-Id: I346046fbc3932b94227c1ac5bee6b0d7c44651e1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-24 11:50:54 +00:00
David Schulz
17b05bc3e8 Clangd: Create correct code assist processor in provider
... for the context of the code assist instead of using a callback from
the text editor.

Change-Id: I636b1b267a944895d4ff732e3c0a8811332ec14f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-17 12:00:18 +00:00
Christian Kandeler
2b09c81682 TextEditor: Handle context help requests like tooltip requests
That is, don't just ask one random hover handler, but try all of them
and use the best one.

Change-Id: I38d0a90e96090c56240314a90f0f428c88fd222c
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-15 09:11:29 +00:00
David Schulz
d739ba8a7d TextEditor: use cursor to comment selection
preparation for multi cursor support

Change-Id: I57d318ee325e3667a6377a972a0eda66e43d0349
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2021-09-07 06:38:08 +00:00
Christian Kandeler
e0e8fda580 ClangCodeModel: Use clangd for completion and function hint
Change-Id: I80160f3a40da18ac178682afe6caba5e5af6e3eb
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-08-23 09:06:31 +00:00
hjk
5731965045 Utils: Use FilePath in DropSupport
Change-Id: Id048d0dab4c58be367a081bb8041214abd6dbf98
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-02 06:59:53 +00:00
Jarek Kobus
0420caa3ce TextEditorWidgetPrivate: Disconnect more signals in d'tor
After the TextEditorWidgetPrivate's d'tor has finished,
compiler starts destructing all the member fields of
TextEditorWidgetPrivate before calling base QObject d'tor.
Some d'tors of some members may still emit signals which
are connected to TextEditorWidgetPrivate's slots. In this
case we may start operating on corrupted internals.

Fixes: QTCREATORBUG-26001
Change-Id: I865cad16601b278fe7f7cf95145557310bb83126
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-13 14:18:59 +00:00
Christian Kandeler
673d596c84 ClangCodeModel: Provide tooltips via clangd
Note that we temporarily lose the ability to hover over an include and
get the full path of the header file. This is a valuable feature that we
need to restore, preferably by fixing clangd itself.
Fixing the remaining few test failures would likely require more
complicated code as well as additional LSP round-trips, and as of now
I'm not convinced it is worth the effort.

Change-Id: I08c72c4bd1268bbd67baeb57bbfd29d9b11303a5
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-30 08:49:24 +00:00
David Schulz
e13c2b7403 MimeDatabase: add FilePath convenience function
Change-Id: I59c825490b3b5c49f3c177584ea4cc885c4f920b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-23 12:03:28 +00:00
David Schulz
693d54a069 Editor: check highlighter for comment chars before auto fold
The KSyntaxHighlighter Definitions provide single and multiline comment
markers. So check against those when trying to automatically fold the
first license header instead of assuming that '#' and "/*" are comment
markers.

Task-number: QTCREATORBUG-25882
Change-Id: I3a84cfc45445caad3b40feb996cfb781a5fb3190
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-22 11:52:52 +00:00
David Schulz
c3abdd56b7 Editor: merge SnippetOverlay::mangle, ::clear and ::hide
... into SnippetOverlay::accept. We currently have no need for just
applying the mangling without closing the overlay.

Change-Id: I98b2f023253f3676d1aed21438251998be1e509c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-11 12:35:03 +00:00
David Schulz
4445876013 Editor: directly use the Link overload of openEditorAt
Change-Id: I5e863600159cc54a99fec5a20df8de1fbc3d745f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-08 07:37:42 +00:00
Christian Kandeler
ff0301635e CppEditor: Tweak test infrastructure
... so we can re-use the "follow symbol" test cases with clangd.

Call Creator like this (clangd needs to be version 12 or later):
$ QTC_CLANGD=<path to clangd> qtcreator -test
'CppEditor,*Follow*,*Switch*' -test 'ClangCodeModel,*dummy*'

During testing, some invalid code in the test cases was uncovered and
fixed.

Change-Id: I9dc650fdba2a27600e6a550420ee873f6fb31d23
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-02 10:52:50 +00:00
David Schulz
fcd93256c0 Snippets: Allow defining a final snippet tabstop
Change-Id: I8b9704f66c9f0ac33dfb9d8f5e970a85bbcf143e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-28 10:39:35 +00:00
David Schulz
919bbe8408 Core: Use Utils::Link for openEditorAt
Change-Id: I246e06b11b4f32f46d7f3ec93df81bcc676aebbe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-25 17:32:59 +00:00
David Schulz
356bfcc9fd Utils: filepathify Link
Change-Id: Ie62500bde139158e776f9698ee0ea00c2a113f93
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-25 17:32:18 +00:00
David Schulz
44e7047450 Editor: Allow defining custom snippet parser function
Task-number: QTCREATORBUG-22406
Change-Id: I21ae9740d348d4e0869029343d51b70f9df9cdac
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-25 08:16:38 +00:00
David Schulz
665c090039 Core: filepathify IDocument
Change-Id: I364a80d070c5f90433309c281c4906ee101a1a1a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-19 09:45:22 +00:00
Eike Ziller
6bb918adab Merge remote-tracking branch 'origin/4.15'
Change-Id: Ic839ab43a723ab22cc83e5b0d823ec6121cb6701
2021-05-10 13:50:58 +02:00
David Schulz
c4605ebc07 TextEditor: Fix painting text mark icons
Only take text marks with icons into account when looking for the three
textmarks with the highest priority to be drawn next to the line number.

Fixes: QTCREATORBUG-25427
Change-Id: I9c0b9cac2e34134e59071a4e2357585b3071c303
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-10 11:18:16 +00:00
David Schulz
a2dadb3d0b TextEditor: Snippet ranges refactoring
Parsed snippets are now reported in chunks of texts and variables. A
variable has a index that can be used to identify matching variables and
maybe a mangler that can be used to modify the variable when applying
the snippet.

This effictively moves the variable matching logic from the overlay to
the parser of the snippet, which is needed to implement the LSP snippet
parser.

Task-number: QTCREATORBUG-22406
Change-Id: I6999554c6c6d0f1887c98bf732473f01aa1f230c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-03 11:12:34 +00:00
David Schulz
ec2449cae4 TextEditor: move snippet overlay into own cpp file
Change-Id: I3343d9abf19e4edc7bd88077bf8fe6666a901e1b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-03 04:11:07 +00:00
David Schulz
c8f8513c8d Snippets: Split error messages out of the parsed snippet
Change-Id: Ic5d6664c86405c558e8bb133b854521e4eaef58a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-28 07:37:24 +00:00
David Schulz
a3c7adecd1 TextEditor: move ParsedSnippet out of snippet
Change-Id: I4e9c7d810fdd0904386f8d3b3481c0a4855c2021
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-26 11:48:47 +00:00
David Schulz
b3c2120dff Editor: add specialized snippet overlay
Split out the snippet functionality into a new derived
overlay implementation.

Change-Id: I2d7fffabe16ce6348ed067eb52ff221420a23285
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-22 04:14:19 +00:00
Eike Ziller
555dbac851 Merge remote-tracking branch 'origin/4.15'
Change-Id: I613b60f7d5cfca19ed611b3777548738d7bd7d67
2021-04-14 11:33:16 +02:00
David Schulz
005f0a3127 TextEditor: Fix highlighting search results at block start
Fixes: QTCREATORBUG-25570
Change-Id: I3450cfed49e07cf96c2a2a9cdfa9a0be7a05c49f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-12 07:27:03 +00:00
Eike Ziller
2800f3b51f Merge remote-tracking branch 'origin/4.15'
Change-Id: I0afcf51d354ffd73a8f2956a7f78b1e4f032677b
2021-04-09 12:42:03 +02:00
David Schulz
dde3fa12ac Editor: Fix RTL move line up/down
Fixes: QTCREATORBUG-25515
Change-Id: I865592938ce0f6c36a9f783e9a379ce5e07d6b88
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-08 04:22:31 +00:00
Eike Ziller
b213c87cf4 Merge remote-tracking branch 'origin/4.15'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp

Change-Id: I722a94f37bdd1d78625cfae503ba6d02ff083c63
2021-03-25 11:06:59 +01:00
David Schulz
9fcab76de6 TextEditor: Fix corrupted cursor after droping text
... by removing excess endEditBlock.

Fixes: QTCREATORBUG-25305
Change-Id: I81fd2ee57a7a470fcc8e78475f336bf2b651a14b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2021-03-24 05:31:10 +00:00
Alessandro Portale
93fbd5be02 Remove dead code "< QT_VERSION_CHECK(5, 14, 0)"
Qt Creator required Qt 5.14 or higher. Let's removed the #idef-ed code
for building against lower Qt versions.

Add a comment in porting.h where we still need such code for sdktool.

Change-Id: Ib330275208eec4a2f285b4b9f480530c171f538a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-18 19:12:39 +00:00
David Schulz
a52f468bc5 Editor: Fix crash when setting language id before document
Change-Id: I735484c7036f6c8b26142d114348295d9b12ae97
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-03-17 14:26:28 +00:00
David Schulz
d187022892 TextEditor: update codeStyle after setting language id
This updates the tab settings to the correct one for the specific
language like C++ or QML. Only observable if the file is not part of a
project. Otherwise the project code style settings will set the language
specific tab settings.

Fixes: QTCREATORBUG-25485
Change-Id: I736646557a213369903fe495e3b5a3a950141961
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-03-17 10:35:21 +00:00
Jacopo Martellini
cc89f72fe5 TextEditor: Add option to prefer single line comments
Fixes: QTCREATORBUG-24017
Change-Id: Icf34710707b51ea9fbd348dd207950cffeedfdd3
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-08 08:36:50 +00:00
Jarek Kobus
e3ae92bc5f TextEditor: Use invokeMethod instead of singleShot timer with 0 delay
Use QCoreApplication::instance() as a context object for the
IAssistProposal deleter.

Change-Id: Idf8cd1955dca146a500da1ea036298455c8a5da1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-02 08:15:28 +00:00
Björn Schäpers
d9cd74f06d Texteditor: Add ability to get margin from indenter
And implement it in the clang-format plugin to use the ColumnLimit from
the style. This would be quite useful if you're working on different
projects with a different ColumnLimit. This way you get an visual
representation and do not only have to rely on clang-format.

Change-Id: Ib0258e3fba6f45f0f46ce612f806527a47868ad9
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-29 17:03:07 +00:00
Eike Ziller
16d25a3cc8 Merge remote-tracking branch 'origin/4.14'
Conflicts:
	src/plugins/qmldesigner/assetexporterplugin/componentexporter.cpp

Change-Id: If742bcd843cf75cf55e07b489ecb7211f0cd9058
2021-01-18 11:50:32 +01:00
David Schulz
8526c7de77 TextEditor: Fix search result highlight for overlapping results
Fixes: QTCREATORBUG-25237
Change-Id: Ib95e49b4db57909b79295f2ff7729560ab45c8a9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-15 10:14:10 +00:00
hjk
206e9f95fb Core: Signal duplicated editors
FakeVim needs some notification even in cases where the
duplication is triggered outside the EditorManager as in
QmlDesigner's qml-editor.

Fixes: QTCREATORBUG-22344
Change-Id: Ia4950ff4b02d3f89779f03ff4c106a07ccff2106
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-14 08:31:44 +00:00
Jarek Kobus
12810caea1 Don't repeat the same code
Change-Id: Ied1d816481bef760a49a4572e9fda1f6ac538daa
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-12-14 14:51:59 +00:00
Alessandro Portale
a3857a996a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Amends: b2a766a79a

Round #2: This time done with Qt Creator's Analyzer, which
found other occurences than run-clang-tidy.py

Change-Id: I479e280c7abcf2d24baccbb0af69ae4bda05198e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-27 13:26:07 +00:00
David Schulz
c5c3214cfb TextEditor: add action to paste without autoFormat
Fixes: QTCREATORBUG-20887
Change-Id: Iedc6b584c9c1cc48804025653d0749e054a406f8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-24 12:20:05 +00:00
Alessandro Portale
b2a766a79a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Change-Id: I71f54244f1e091315dac2943d9e1bfad6efa56a9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-19 08:42:14 +00:00
David Schulz
6e846b6606 TextEditor: skip painting annotations for disabled text marks
Change-Id: Id05bfe5bd120b2bbb2e2b70fb29a99b8c430e459
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-27 07:38:30 +00:00
David Schulz
0ca9ea353c Editor: Do not use disabled code color for right margin highlight
Fixes: QTCREATORBUG-17174
Change-Id: I68729d5a44b23fe46b810054a1dc472ffd63e272
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-21 04:32:27 +00:00
David Schulz
f220cb0e23 Revert "Editor: Make line spacing adjustable"
This does not work with text wrapping since there are multiple
QTextLines inside a block but we can not adjust the line hight inside a
block. This needs to be addressed inside Qt.

This reverts commit dc64f3207b.

Change-Id: If6c28056da9891eeeb75f5939a42f08360013a80
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-20 04:35:42 +00:00
David Schulz
05ad4e3daa TextEditor: fix selection highlight
Also compare the anchor when looking for the selection. Otherwise we
might get a selection highlight that expands on adjacent extra
selections like code model warnings.

Change-Id: Ib8460c1089ed69d14b7a408ca70e7ac1f8642f6e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-19 04:16:13 +00:00
David Schulz
3c281aa483 Editor: Select moved text after drag and drop
Fixes: QTCREATORBUG-24245
Change-Id: I9da52424128825f729d5d20e2c7fd095120477c6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-06 07:54:27 +00:00