Repository navigation
Fix grep highlighting, pwd at /, and cd tab completion - #147
Open
mstellaris wants to merge 1 commit into
Open
mstellaris wants to merge 1 commit into
mstellaris wants to merge 1 commit into
Conversation
- grep: highlight in one global RegExp pass over the original text with a real "match" style. The old loop used a style that doesn't exist and re-ran replaceAll per match over already-modified text, so a pattern found in an escape code (grep 3 README.md) nested codes into garbage. An invalid pattern now prints an error instead of throwing. - pwd (and the claude banner) printed "//" at the root; both now use a shared _cwdPath() helper. - cd <Tab> filtered out every entry of the current directory, so it never completed. It now offers directories: the _DIRS keys and /home entries. Adds 11 tests; 7 fail on the previous code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
👷 Deploy request for rootvc-cli-website pending review.Visit the deploys page to approve it
|
This branch has not been deployed
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.
Three small bugs in the terminal, each with a test.
grep corrupts its own output
grephighlighted matches withcolorText(match, "files"), butfilesisn't astyle, so no colour was ever applied. Only the reset code
\x1b[0;38mwas added.It then ran
replaceAllonce per match over the already-modified text, so apattern that occurs in an escape code (
0,3,8,;,[) matches insidethe codes it just inserted. Try
su root, thengrep 3 README.md: the outputfills with nested escape sequences.
Now: one
String.replacewith a global RegExp over the original text, and a newmatchstyle (bold red, like GNU grep). An invalid pattern (grep ( README.md)prints
grep: invalid patterninstead of throwing into"Command failed to load required assets". Patterns stay regexes, as in real grep.
(#141 escapes metacharacters but keeps the
filesstyle and the per-matchreplaceAllloop, so it doesn't fix this.)pwdprints//at the rootcd /thenpwdprinted//, becausecwdis stored as/and the codealways prefixed another slash.
claudeshowed the same path in its banner.Both now use a shared
_cwdPath()helper.cd <Tab>never completes anythingThe completion filter kept entries
!_DIRS[term.cwd].includes(dir). Every entry_filesHere()returns is in_DIRS[term.cwd], so the list was always empty.Now it offers directories: the
_DIRSkeys (bin,home) and the entries of/home. Plain files likeid_rsaare still excluded.Tests
tests/commands.test.js:pwdtable; grep highlights each match once,treats the pattern as a regex, and reports an invalid pattern.
tests/terminal.test.js:cdcompletion from/, from/home, a uniqueprefix, and no plain files from
~.11 new tests, 7 of which fail on the previous code. Full suite: 168 passed.
🤖 Generated with Claude Code