@@ -1229,14 +1229,40 @@ namespace {
1229
1229
// --------------------------------------------------------------------------
1230
1230
// Remove "Line 123: " prefix from hit line (UTF‑16)
1231
1231
// --------------------------------------------------------------------------
1232
- std::wstring stripHitPrefix (const std::wstring& w) {
1233
- size_t pos = w.find (L" Line " );
1234
- if (pos == std::wstring::npos) return w;
1235
- pos += 5 ; // skip "Line "
1236
- while (pos < w.size () && iswdigit (w[pos])) ++pos;
1237
- if (pos < w.size () && w[pos] == L' :' ) ++pos;
1238
- while (pos < w.size () && iswspace (w[pos])) ++pos;
1239
- return w.substr (pos);
1232
+ std::wstring stripHitPrefix (const std::wstring& w)
1233
+ {
1234
+ size_t i = 0 ;
1235
+
1236
+ // 1. Skip leading whitespace (indentation).
1237
+ while (i < w.size () && iswspace (w[i]))
1238
+ ++i;
1239
+
1240
+ // 2. Skip an optional alphabetic word such as "Line", "Zeile", etc.
1241
+ while (i < w.size () && iswalpha (w[i]))
1242
+ ++i;
1243
+
1244
+ // 3. Skip one single space after that word, if present.
1245
+ if (i < w.size () && w[i] == L' ' )
1246
+ ++i;
1247
+
1248
+ // 4. Consume at least one digit (line number).
1249
+ size_t digitStart = i;
1250
+ while (i < w.size () && iswdigit (w[i]))
1251
+ ++i;
1252
+ if (i == digitStart || i >= w.size ())
1253
+ return w; // Not our format – return unchanged.
1254
+
1255
+ // 5. Expect exactly one colon.
1256
+ if (w[i] != L' :' )
1257
+ return w; // Not our format – return unchanged.
1258
+ ++i;
1259
+
1260
+ // 6. Skip whitespace after the colon.
1261
+ while (i < w.size () && iswspace (w[i]))
1262
+ ++i;
1263
+
1264
+ // 7. Return the remainder: the actual hit text.
1265
+ return w.substr (i);
1240
1266
}
1241
1267
1242
1268
// --------------------------------------------------------------------------
0 commit comments