| 2322 | } |
| 2323 | |
| 2324 | bool ScintillaEditView::undoStreamComment(bool tryBlockComment) |
| 2325 | { |
| 2326 | QByteArray commentStart; |
| 2327 | QByteArray commentEnd; |
| 2328 | QByteArray commentLineSymbol; |
| 2329 | |
| 2330 | QByteArray symbolStart; |
| 2331 | QByteArray symbolEnd; |
| 2332 | QByteArray symbol; |
| 2333 | |
| 2334 | const int charbufLen = 10; |
| 2335 | QByteArray charbuf; |
| 2336 | charbuf.reserve(charbufLen); |
| 2337 | |
| 2338 | bool retVal = false; |
| 2339 | |
| 2340 | QsciLexer* pLexer = this->lexer(); |
| 2341 | //-- Avoid side-effects (e.g. cursor moves number of comment-characters) when file is read-only. |
| 2342 | if (this->isReadOnly()) |
| 2343 | return false; |
| 2344 | |
| 2345 | if (pLexer->lexer() == nullptr) |
| 2346 | { |
| 2347 | return false; |
| 2348 | } |
| 2349 | else |
| 2350 | { |
| 2351 | commentLineSymbol = pLexer->getCommentLineSymbol(); |
| 2352 | commentStart = pLexer->getCommentStart(); |
| 2353 | commentEnd = pLexer->getCommentEnd(); |
| 2354 | } |
| 2355 | |
| 2356 | |
| 2357 | // BlockToStreamComment: If there is no stream-comment symbol and we came not from doBlockComment, try the block comment: |
| 2358 | if (commentStart.isEmpty() || commentEnd.isEmpty()) |
| 2359 | { |
| 2360 | if (!commentLineSymbol.isEmpty() && tryBlockComment) |
| 2361 | return doBlockComment(cm_uncomment); |
| 2362 | else |
| 2363 | return false; |
| 2364 | } |
| 2365 | |
| 2366 | QByteArray start_comment(commentStart); |
| 2367 | QByteArray end_comment(commentEnd); |
| 2368 | QByteArray white_space(" "); |
| 2369 | size_t start_comment_length = start_comment.length(); |
| 2370 | size_t end_comment_length = end_comment.length(); |
| 2371 | |
| 2372 | // do as long as stream-comments are within selection |
| 2373 | do |
| 2374 | { |
| 2375 | auto selectionStart = this->execute(SCI_GETSELECTIONSTART); |
| 2376 | auto selectionEnd = this->execute(SCI_GETSELECTIONEND); |
| 2377 | auto caretPosition = this->execute(SCI_GETCURRENTPOS); |
| 2378 | auto docLength = this->execute(SCI_GETLENGTH); |
| 2379 | |
| 2380 | // checking if caret is located in _beginning_ of selected block |
| 2381 | bool move_caret = caretPosition < selectionEnd; |
nothing calls this directly
no test coverage detected