Skip to content

Commit 44e1dd8

Browse files
committed
fix of leading spaces crash
1 parent 429912d commit 44e1dd8

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/ResultDock.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,8 @@ void ResultDock::formatHitsLines(const SciSendFn& sciSend,
374374
// Trim any CR/LF at end
375375
while (!raw.empty() && (raw.back() == '\r' || raw.back() == '\n'))
376376
raw.pop_back();
377-
378-
// Trim leading spaces/tabs
379-
size_t lead = raw.find_first_not_of(" \t");
380-
std::string_view sliceBytes =
381-
(lead == std::string::npos)
382-
? std::string_view{}
383-
: std::string_view(raw).substr(lead);
377+
378+
std::string_view sliceBytes(raw);
384379

385380
// --- IMPORTANT: produce two representations ---
386381
// 1) UTF-8 bytes for accurate byte‑offset highlighting
@@ -395,8 +390,7 @@ void ResultDock::formatHitsLines(const SciSendFn& sciSend,
395390
size_t prefixU8Len = Encoding::wstringToUtf8(prefixW).size();
396391

397392
// Compute byte‑offset of match start within sliceU8
398-
Sci_Position absTrimmed = sciSend(SCI_POSITIONFROMLINE, lineZero, 0)
399-
+ static_cast<Sci_Position>(lead);
393+
Sci_Position absTrimmed = sciSend(SCI_POSITIONFROMLINE, lineZero, 0);
400394
size_t relBytes = static_cast<size_t>(h.pos - absTrimmed);
401395

402396
// Compute byte‑lengths for the match portion

0 commit comments

Comments
 (0)