Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/decorators/MarkerAppDecorator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,38 @@ QColor MarkerAppDecorator::markerColor(int i) const

void MarkerAppDecorator::mark(ScintillaNext *editor, int i)
{
//const int mainSelection = editor->mainSelection();
//const int selectionStart = editor->selectionNStart(mainSelection);
//const int selectionEnd = editor->selectionNEnd(mainSelection);
const int mainSelection = editor->mainSelection();
const int selectionStart = editor->selectionNStart(mainSelection);
const int selectionEnd = editor->selectionNEnd(mainSelection);

const int curPos = editor->currentPos();
const int wordStart = editor->wordStartPosition(curPos, true);
const int wordEnd = editor->wordEndPosition(wordStart, true);
// If there is a selection, use it verbatim; otherwise fall back to the word at the cursor
int textStart, textEnd;
bool isWholeWord = false;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see isWholeWord is set but not used. Is it intended to be used as part of the flags? Or just not needed at all any more?

if (selectionStart != selectionEnd) {
textStart = selectionStart;
textEnd = selectionEnd;
} else {
isWholeWord = true;
const int curPos = editor->currentPos();
textStart = editor->wordStartPosition(curPos, true);
textEnd = editor->wordEndPosition(textStart, true);
}

// Make sure the selection is on word boundaries
if (wordStart == wordEnd) {
if (textStart == textEnd) {
return;
}

// Limit the size of the selection
if (textEnd - textStart > 1024) {
return;
}

int indicator = editor->allocateIndicator(QString("marker_%1").arg(i));
editor->setIndicatorCurrent(indicator);

const QByteArray selText = editor->get_text_range(wordStart, wordEnd);
const QByteArray selText = editor->get_text_range(textStart, textEnd);
Sci_TextToFind ttf {{0, (Sci_PositionCR)editor->length()}, selText.constData(), {-1, -1}};
const int flags = SCFIND_WHOLEWORD;
const int flags = SCFIND_MATCHCASE;

while (editor->send(SCI_FINDTEXT, flags, (sptr_t)&ttf) != -1) {
editor->indicatorFillRange(ttf.chrgText.cpMin, ttf.chrgText.cpMax - ttf.chrgText.cpMin);
Expand All @@ -93,4 +106,4 @@ void MarkerAppDecorator::clearAll(ScintillaNext *editor)
for (int i = 0; i < marker_colors.size(); i++) {
clear(editor, i);
}
}
}
Loading