@fresh-editor/fresh-editor 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -346,7 +346,8 @@ export function parseGrepLine(line: string): {
346
346
  */
347
347
  export function parseGrepOutput(
348
348
  stdout: string,
349
- maxResults: number = 100
349
+ maxResults: number = 100,
350
+ debug?: (msg: string) => void
350
351
  ): Array<{ file: string; line: number; column: number; content: string }> {
351
352
  const results: Array<{
352
353
  file: string;
@@ -355,14 +356,16 @@ export function parseGrepOutput(
355
356
  content: string;
356
357
  }> = [];
357
358
 
358
- for (const line of stdout.split("\n")) {
359
- if (!line.trim()) continue;
359
+ for (const line of stdout.split(/\r?\n/)) {
360
+ if (!line) continue;
360
361
  const match = parseGrepLine(line);
361
362
  if (match) {
362
363
  results.push(match);
363
364
  if (results.length >= maxResults) {
364
365
  break;
365
366
  }
367
+ } else if (debug) {
368
+ debug(`[parseGrepOutput] failed to parse line: ${line}`);
366
369
  }
367
370
  }
368
371
 
@@ -784,7 +787,8 @@ export class Finder<T> {
784
787
  // Parse as grep output by default
785
788
  const parsed = parseGrepOutput(
786
789
  result.stdout,
787
- this.config.maxResults
790
+ this.config.maxResults,
791
+ (msg) => this.editor.debug(msg)
788
792
  ) as unknown as T[];
789
793
  this.updatePromptResults(parsed);
790
794
 
@@ -827,9 +831,26 @@ export class Finder<T> {
827
831
  }
828
832
  } catch (e) {
829
833
  const errorMsg = String(e);
830
- if (!errorMsg.includes("killed") && !errorMsg.includes("not found")) {
831
- this.editor.setStatus(`Search error: ${e}`);
834
+ // "killed" / "not found" come from the cancellation path (a
835
+ // newer search aborted this one). Suppress those entirely —
836
+ // the user didn't ask for them.
837
+ if (errorMsg.includes("killed") || errorMsg.includes("not found")) {
838
+ return;
832
839
  }
840
+ // Render the error inside the overlay's result list itself.
841
+ // The status bar is shared and clobbered by other code paths,
842
+ // so it's not a reliable place to surface a feature-scoped
843
+ // error — the overlay is where the user is looking.
844
+ this.promptState.results = [];
845
+ this.promptState.entries = [];
846
+ const display = errorMsg.replace(/^Error:\s*/, "");
847
+ this.editor.setPromptSuggestions([
848
+ {
849
+ text: `⚠ ${display}`,
850
+ value: "",
851
+ disabled: true,
852
+ },
853
+ ]);
833
854
  }
834
855
  }
835
856