Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/ktexteditor/files/, kde-frameworks/ktexteditor/
Date: Sat, 09 Apr 2022 16:07:49
Message-Id: 1649520184.04a3f091de5fc81e28e024ebe732081e6598fcea.asturm@gentoo
1 commit: 04a3f091de5fc81e28e024ebe732081e6598fcea
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 9 15:37:28 2022 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 9 16:03:04 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=04a3f091
7
8 kde-frameworks/ktexteditor: Fix crash and comment toggling
9
10 Upstream commit ad82b876016367bd9765185dba84600985e5d0fd
11 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=451593
12
13 Upstream commit 1173d5184e8b073790556dbdba92a8b8abdd62dc
14 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=451471
15
16 Package-Manager: Portage-3.0.30, Repoman-3.0.3
17 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
18
19 ...xteditor-5.92.0-fix-crash-w-stale-indexes.patch | 29 ++++++
20 .../ktexteditor-5.92.0-fix-toggle-comment.patch | 112 +++++++++++++++++++++
21 .../ktexteditor/ktexteditor-5.92.0-r1.ebuild | 60 +++++++++++
22 3 files changed, 201 insertions(+)
23
24 diff --git a/kde-frameworks/ktexteditor/files/ktexteditor-5.92.0-fix-crash-w-stale-indexes.patch b/kde-frameworks/ktexteditor/files/ktexteditor-5.92.0-fix-crash-w-stale-indexes.patch
25 new file mode 100644
26 index 000000000000..b77a72a3e502
27 --- /dev/null
28 +++ b/kde-frameworks/ktexteditor/files/ktexteditor-5.92.0-fix-crash-w-stale-indexes.patch
29 @@ -0,0 +1,29 @@
30 +From ad82b876016367bd9765185dba84600985e5d0fd Mon Sep 17 00:00:00 2001
31 +From: Waqar Ahmed <waqar.17a@×××××.com>
32 +Date: Fri, 18 Mar 2022 10:14:28 +0500
33 +Subject: [PATCH] Fix crash with stale indexes
34 +
35 +BUG: 451593
36 +---
37 + src/completion/katecompletionmodel.cpp | 5 +++++
38 + 1 file changed, 5 insertions(+)
39 +
40 +diff --git a/src/completion/katecompletionmodel.cpp b/src/completion/katecompletionmodel.cpp
41 +index 1e241f0d..d9bb8421 100644
42 +--- a/src/completion/katecompletionmodel.cpp
43 ++++ b/src/completion/katecompletionmodel.cpp
44 +@@ -914,6 +914,11 @@ QModelIndex KateCompletionModel::mapToSource(const QModelIndex &proxyIndex) cons
45 + }
46 +
47 + if (Group *g = groupOfParent(proxyIndex)) {
48 ++ if (!m_rowTable.contains(g)) {
49 ++ qWarning() << Q_FUNC_INFO << "Stale proxy index for which there is no group";
50 ++ return {};
51 ++ }
52 ++
53 + if (proxyIndex.row() >= 0 && proxyIndex.row() < (int)g->filtered.size()) {
54 + ModelRow source = g->filtered[proxyIndex.row()].sourceRow();
55 + return source.second.sibling(source.second.row(), proxyIndex.column());
56 +--
57 +GitLab
58 +
59
60 diff --git a/kde-frameworks/ktexteditor/files/ktexteditor-5.92.0-fix-toggle-comment.patch b/kde-frameworks/ktexteditor/files/ktexteditor-5.92.0-fix-toggle-comment.patch
61 new file mode 100644
62 index 000000000000..bac8cd017e68
63 --- /dev/null
64 +++ b/kde-frameworks/ktexteditor/files/ktexteditor-5.92.0-fix-toggle-comment.patch
65 @@ -0,0 +1,112 @@
66 +From 1173d5184e8b073790556dbdba92a8b8abdd62dc Mon Sep 17 00:00:00 2001
67 +From: Waqar Ahmed <waqar.17a@×××××.com>
68 +Date: Mon, 14 Mar 2022 09:44:54 +0500
69 +Subject: [PATCH] Fix toggle comment with space at the start
70 +
71 +BUG: 451471
72 +---
73 + autotests/src/katedocument_test.cpp | 48 +++++++++++++++++++++++++++++
74 + autotests/src/katedocument_test.h | 1 +
75 + src/document/katedocument.cpp | 10 +++++-
76 + 3 files changed, 58 insertions(+), 1 deletion(-)
77 +
78 +diff --git a/autotests/src/katedocument_test.cpp b/autotests/src/katedocument_test.cpp
79 +index f0946829..a842f960 100644
80 +--- a/autotests/src/katedocument_test.cpp
81 ++++ b/autotests/src/katedocument_test.cpp
82 +@@ -851,4 +851,52 @@ void KateDocumentTest::testKeepUndoOverReload()
83 + QCOMPARE(doc.text(), insertedText + initialText);
84 + }
85 +
86 ++void KateDocumentTest::testToggleComment()
87 ++{
88 ++ { // BUG: 451471
89 ++ KTextEditor::DocumentPrivate doc;
90 ++ QVERIFY(doc.highlightingModes().contains(QStringLiteral("Python")));
91 ++ doc.setHighlightingMode(QStringLiteral("Python"));
92 ++ const QString original = QStringLiteral("import hello;\n def method():");
93 ++ doc.setText(original);
94 ++ QVERIFY(doc.lines() == 2);
95 ++
96 ++ doc.commentSelection(doc.documentRange(), {1, 2}, false, 0); // 0 == ToggleComment
97 ++ QCOMPARE(doc.text(), QStringLiteral("#import hello;\n #def method():"));
98 ++
99 ++ doc.commentSelection(doc.documentRange(), {1, 2}, false, 0); // 0 == ToggleComment
100 ++ QCOMPARE(doc.text(), original);
101 ++ }
102 ++
103 ++ { // Comment C++;
104 ++ KTextEditor::DocumentPrivate doc;
105 ++ QVERIFY(doc.highlightingModes().contains(QStringLiteral("C++")));
106 ++ doc.setHighlightingMode(QStringLiteral("C++"));
107 ++ QString original = QStringLiteral("#include<iostream>\nint main()\n{\nreturn 0;\n}\n");
108 ++ doc.setText(original);
109 ++ QVERIFY(doc.lines() == 6);
110 ++
111 ++ doc.commentSelection(doc.documentRange(), {5, 0}, false, 0); // 0 == ToggleComment
112 ++ QCOMPARE(doc.text(), QStringLiteral("// #include<iostream>\n// int main()\n// {\n// return 0;\n// }\n"));
113 ++
114 ++ doc.commentSelection(doc.documentRange(), {5, 0}, false, 0); // 0 == ToggleComment
115 ++ QCOMPARE(doc.text(), original);
116 ++
117 ++ // Comment just a portion
118 ++ doc.commentSelection(Range(1, 0, 1, 3), Cursor(1, 3), false, 0);
119 ++ QCOMPARE(doc.text(), QStringLiteral("#include<iostream>\n/*int*/ main()\n{\nreturn 0;\n}\n"));
120 ++ doc.commentSelection(Range(1, 0, 1, 7), Cursor(1, 3), false, 0);
121 ++ QCOMPARE(doc.text(), original);
122 ++
123 ++ // mixed, one line commented, one not => both get commented
124 ++ original = QStringLiteral(" // int main()\n{}");
125 ++ doc.setText(original);
126 ++ doc.commentSelection(doc.documentRange(), {1, 2}, false, 0);
127 ++ QCOMPARE(doc.text(), QStringLiteral("// // int main()\n// {}"));
128 ++ doc.commentSelection(doc.documentRange(), {1, 2}, false, 0);
129 ++ // after uncommenting, we get original text back with one line commented
130 ++ QCOMPARE(doc.text(), original);
131 ++ }
132 ++}
133 ++
134 + #include "katedocument_test.moc"
135 +diff --git a/autotests/src/katedocument_test.h b/autotests/src/katedocument_test.h
136 +index c3b24b4c..0076f879 100644
137 +--- a/autotests/src/katedocument_test.h
138 ++++ b/autotests/src/katedocument_test.h
139 +@@ -46,6 +46,7 @@ private Q_SLOTS:
140 + void testIndentOnPaste();
141 + void testAboutToSave();
142 + void testKeepUndoOverReload();
143 ++ void testToggleComment();
144 + };
145 +
146 + #endif // KATE_DOCUMENT_TEST_H
147 +diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp
148 +index 56e8fc7d..b72592b6 100644
149 +--- a/src/document/katedocument.cpp
150 ++++ b/src/document/katedocument.cpp
151 +@@ -3995,7 +3995,11 @@ bool KTextEditor::DocumentPrivate::removeStartLineCommentFromSelection(KTextEdit
152 + bool allLinesAreCommented = true;
153 + for (int line = endLine; line >= startLine; line--) {
154 + const auto ln = m_buffer->plainLine(line);
155 +- if (!ln->startsWith(shortCommentMark) && !ln->startsWith(longCommentMark)) {
156 ++ const QString &text = ln->text();
157 ++ QStringView textView(text.data(), text.size());
158 ++ // Must trim any spaces at the beginning
159 ++ textView = textView.trimmed();
160 ++ if (!textView.startsWith(shortCommentMark) && !textView.startsWith(longCommentMark)) {
161 + allLinesAreCommented = false;
162 + break;
163 + }
164 +@@ -4031,6 +4035,10 @@ void KTextEditor::DocumentPrivate::commentSelection(KTextEditor::Range selection
165 +
166 + int startAttrib = 0;
167 + Kate::TextLine ln = kateTextLine(line);
168 ++ if (!ln) {
169 ++ qWarning() << __FUNCTION__ << __LINE__ << "Unexpected null TextLine for " << line << " lineCount: " << lines();
170 ++ return;
171 ++ }
172 +
173 + if (selectionCol < ln->length()) {
174 + startAttrib = ln->attribute(selectionCol);
175 +--
176 +GitLab
177 +
178
179 diff --git a/kde-frameworks/ktexteditor/ktexteditor-5.92.0-r1.ebuild b/kde-frameworks/ktexteditor/ktexteditor-5.92.0-r1.ebuild
180 new file mode 100644
181 index 000000000000..a09c6631374b
182 --- /dev/null
183 +++ b/kde-frameworks/ktexteditor/ktexteditor-5.92.0-r1.ebuild
184 @@ -0,0 +1,60 @@
185 +# Copyright 1999-2022 Gentoo Authors
186 +# Distributed under the terms of the GNU General Public License v2
187 +
188 +EAPI=8
189 +
190 +PVCUT=$(ver_cut 1-2)
191 +QTMIN=5.15.2
192 +VIRTUALX_REQUIRED="test"
193 +inherit ecm kde.org
194 +
195 +DESCRIPTION="Framework providing a full text editor component"
196 +
197 +LICENSE="LGPL-2+"
198 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
199 +IUSE="+editorconfig"
200 +
201 +RESTRICT="test"
202 +
203 +DEPEND="
204 + >=dev-qt/qtdeclarative-${QTMIN}:5
205 + >=dev-qt/qtgui-${QTMIN}:5
206 + >=dev-qt/qtprintsupport-${QTMIN}:5
207 + >=dev-qt/qtwidgets-${QTMIN}:5
208 + >=dev-qt/qtxml-${QTMIN}:5
209 + =kde-frameworks/karchive-${PVCUT}*:5
210 + =kde-frameworks/kauth-${PVCUT}*:5
211 + =kde-frameworks/kcodecs-${PVCUT}*:5
212 + =kde-frameworks/kcompletion-${PVCUT}*:5
213 + =kde-frameworks/kconfig-${PVCUT}*:5
214 + =kde-frameworks/kconfigwidgets-${PVCUT}*:5
215 + =kde-frameworks/kcoreaddons-${PVCUT}*:5
216 + =kde-frameworks/kguiaddons-${PVCUT}*:5
217 + =kde-frameworks/ki18n-${PVCUT}*:5
218 + =kde-frameworks/kiconthemes-${PVCUT}*:5
219 + =kde-frameworks/kio-${PVCUT}*:5
220 + =kde-frameworks/kitemviews-${PVCUT}*:5
221 + =kde-frameworks/kjobwidgets-${PVCUT}*:5
222 + =kde-frameworks/kparts-${PVCUT}*:5
223 + =kde-frameworks/ktextwidgets-${PVCUT}*:5
224 + =kde-frameworks/kwidgetsaddons-${PVCUT}*:5
225 + =kde-frameworks/kxmlgui-${PVCUT}*:5
226 + =kde-frameworks/sonnet-${PVCUT}*:5
227 + =kde-frameworks/syntax-highlighting-${PVCUT}*:5
228 + editorconfig? ( app-text/editorconfig-core-c )
229 +"
230 +RDEPEND="${DEPEND}"
231 +BDEPEND="test? ( >=kde-frameworks/kservice-${PVCUT}:5 )"
232 +
233 +PATCHES=(
234 + "${FILESDIR}/${P}-fix-crash-w-stale-indexes.patch" # KDE-bug 451593
235 + "${FILESDIR}/${P}-fix-toggle-comment.patch" # KDE-bug 451471
236 +)
237 +
238 +src_configure() {
239 + local mycmakeargs=(
240 + $(cmake_use_find_package editorconfig EditorConfig)
241 + )
242 +
243 + ecm_src_configure
244 +}