Repository navigation
Fix search on Linux - #94
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Linux-specific breakages in the sidebar “Find in Folder” search by preventing a crash when no editor file is active and by making ripgrep-based search more resilient to partial filesystem read errors and non-JSON stdout output.
Changes:
- Prevents a
TypeErrorin the search sidebar when no file is open by avoiding destructuring onundefined. - Improves ripgrep search robustness by tolerating exit code
2, skipping unparseable stdout lines, and processing any remaining stdout buffer on process close.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/renderer/src/node/ripgrepSearcher.js |
Makes ripgrep searching tolerant of partial errors and non-JSON stdout, and processes leftover buffered output. |
src/renderer/src/components/sideBar/search.vue |
Avoids crashing search sidebar initialization when there is no active file selection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
lgtm, thanks for this :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two issues that completely break the sidebar search functionality in certain scenarios. It happened on my ArchLinux, I am not sure whether it also happens on other platforms.
Fixes
1. Crash when no file is opened
File:
src/renderer/src/components/sideBar/search.vueWhen the search sidebar is opened without any active file,
searchMatches.valueisundefined. The destructuringconst { selectedText } = searchMatches.valuethrows aTypeError, causing the search panel to fail initialization.Fix: Use optional chaining:
searchMatches.value?.selectedText.2. Ripgrep errors aborting the entire search
File:
src/renderer/src/node/ripgrepSearcher.jsWhen
ripgrepencounters permission-denied files or broken symlinks, it exits with code2. The current implementation rejects the whole promise oncode > 1, discarding all valid results found in accessible files. Additionally, non-JSON lines instdout(e.g., warning messages mixed into output in some environments) can cause unhandledJSON.parseexceptions.Fixes:
stdoutline intry/catchto skip unparseable output.closeevent so the last line isn't lost.2; instead, log the stderr as a warning and resolve with whatever results were already found.