@@ -148,6 +148,23 @@ static bool isDelimitedState(State state)
148
148
|| state == State::CODE_ARGUMENTS;
149
149
}
150
150
151
+ static bool isIndentingState (State state)
152
+ {
153
+ return state == State::CONTENT_BLOCK
154
+ || state == State::CODE_BLOCK
155
+ || state == State::CODE_ARGUMENTS
156
+ || state == State::MATH_ARGUMENTS;
157
+ }
158
+
159
+ static bool isLeftLeaningState (State state)
160
+ {
161
+ return state == State::CODE_BLOCK
162
+ || state == State::CODE_LINE
163
+ || state == State::MATH
164
+ || state == State::CONTENT_RAW
165
+ || state == State::CONTENT_RAW_BLOCK;
166
+ }
167
+
151
168
std::optional<int > CodeModel::findMatchingBracket (int pos) const
152
169
{
153
170
QTextBlock block = d_document->findBlock (pos);
@@ -184,14 +201,6 @@ std::optional<int> CodeModel::findMatchingBracket(int pos) const
184
201
return std::nullopt;
185
202
}
186
203
187
- static bool isIndentingState (State state)
188
- {
189
- return state == State::CONTENT_BLOCK
190
- || state == State::CODE_BLOCK
191
- || state == State::CODE_ARGUMENTS
192
- || state == State::MATH_ARGUMENTS;
193
- }
194
-
195
204
std::optional<StateSpan> CodeModel::spanAtPosition (QTextBlock block, int globalPos) const
196
205
{
197
206
Q_ASSERT (d_document->findBlock (globalPos) == block);
@@ -282,6 +291,21 @@ QTextBlock CodeModel::findMatchingIndentBlock(QTextBlock block) const
282
291
return block;
283
292
}
284
293
294
+ bool CodeModel::startsLeftLeaningSpan (QTextBlock block) const
295
+ {
296
+ auto * blockData = BlockData::get<StateSpansBlockData>(block);
297
+ if (!blockData) {
298
+ return false ;
299
+ }
300
+
301
+ for (const StateSpan& span : blockData->stateSpans ()) {
302
+ if (span.startPos >= 0 && isLeftLeaningState (span.state )) {
303
+ return true ;
304
+ }
305
+ }
306
+ return false ;
307
+ }
308
+
285
309
std::tuple<State, State> CodeModel::getStatesForBracketInsertion (QTextCursor cursor) const
286
310
{
287
311
State prevState = State::INVALID;
0 commit comments