Commit Graph

381 Commits

Author SHA1 Message Date
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
David Schulz
dc64f3207b Editor: Make line spacing adjustable
Fixes: QTCREATORBUG-13727
Change-Id: I3dbc3277795b339bced81dc6c5a048c828183cb6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-01 12:11:09 +00:00
David Schulz
f6b3f41d19 Editor: Skip auto inserted characters with tab
Fixes: QTCREATORBUG-12641
Change-Id: I9800b939118d1e46d202454a66729cd81d2c08b3
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-29 07:17:05 +00:00
Eike Ziller
bbe95b5733 Qt6: Various include, QPrinter, and QFlags adaptations
Task-number: QTCREATORBUG-24098
Change-Id: I7aca7d25a063c84d6eec14c2c5789357ce56a7b3
Reviewed-by: hjk <hjk@qt.io>
2020-09-28 15:51:21 +00:00
Eike Ziller
cc502e3667 Remove bool return value from IEditor::restoreState()
It's never used, and actually there wouldn't be any sensible thing to do
with it.

Change-Id: Id8a8df18c7db4b98e5abbc034240bb90dc1dcaa9
Reviewed-by: hjk <hjk@qt.io>
2020-09-24 13:02:56 +00:00
Eike Ziller
423ea729f8 Merge remote-tracking branch 'origin/4.13' into master
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/mcusupport/mcusupportoptions.cpp

Change-Id: I3fd0d0a6a3ff30bb990da3dc0f78e69f9e1247ef
2020-09-23 10:11:44 +02:00
David Schulz
da2e8bbf7b Editor: fix hanging when using invalid printer page rect
Some printer seem to return an empty page rect for some configuration
which results in an invalide page count and a freezing ui. Do not print
anything and return in that case.

Fixes: QTCREATORBUG-24110
Change-Id: I42349bc97734e3f6a67502482d2b02959e865665
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-09-21 10:18:29 +00:00
David Schulz
d99e00c49f TextEditor: allow highlightings in selections
If the selection foregound color is undefined do not overwrite the
already applied highlighting.

Fixes: QTCREATORBUG-24656
Change-Id: Ia125e8e6b9efba73d5a13facc2446a793d59f5c3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-21 07:16:43 +00:00
Eike Ziller
20f51bc642 Merge remote-tracking branch 'origin/4.13' into master
Conflicts:
	src/plugins/languageclient/languageclientcompletionassist.cpp

Change-Id: If12e1c532e5623ef063681309a918e7b51117b1c
2020-09-14 10:12:14 +02:00
David Schulz
3b23cab385 TextEditor: Use selection format from the setting
Overwrites the format generated by QPlainTextEdit::getPaintContext()

Amends 9182d4eda7.

Fixes: QTCREATORBUG-24479
Change-Id: Ia226a74442dbbdbae42e8da5dee9e4d7399b677c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-09-11 11:48:29 +00:00
Eike Ziller
7aa0b1ea6b TextEditor: Fix build with Qt6
Adapt to QStringRef and QAbstractItemView::viewOptions() removal

Task-number: QTCREATORBUG-24098
Change-Id: Ia2d446312f68bd60143796284d31f5bba56aa0ed
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-09-08 07:47:30 +00:00