mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-14 11:19:42 +02:00
fix(preview): a shell prompt's trailing $ or # stays out of its folder link (#604 merge-time fix)
The folder link pattern treats `:` as a boundary and allows `$`/`#` in a path, so every default bash prompt (`user@host:~/proj$`, `root@c:/workspace#`) became a folder link to a path that does not exist, and clicking it showed "Folder not found". folderLinkPath now strips them, so the link opens the prompt's cwd. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2163,7 +2163,9 @@ const FOLDER_PATH_LINK_PATTERN =
|
||||
* without a slash at the end is prose, not a folder.
|
||||
*/
|
||||
function folderLinkPath(candidate) {
|
||||
const path = String(candidate || '').replace(/[.,:;!?'"]+$/, '');
|
||||
// `$` and `#` too: a shell prompt (`user@host:~/proj$ `, `root@c:/app# `) ends
|
||||
// its cwd with one. A folder whose name really ends in one links one short.
|
||||
const path = String(candidate || '').replace(/[.,:;!?'"$#]+$/, '');
|
||||
if (!path || path === '~/' || /^\/[^/]+\/$/.test(path)) return null;
|
||||
if (path.endsWith('/')) return /[^/.]/.test(path) ? path : null;
|
||||
if (!path.startsWith('/') && !path.startsWith('~/')) return null;
|
||||
|
||||
@@ -90,6 +90,11 @@ describe('findFilePathLinks', () => {
|
||||
expect(paths('see src/a.ts:120.')).toEqual(['src/a.ts']);
|
||||
});
|
||||
|
||||
it("keeps a shell prompt's trailing `$` or `#` out of the folder it links", () => {
|
||||
expect(paths('arkon@tnode:~/default/claudeman$ ls')).toEqual(['~/default/claudeman']);
|
||||
expect(paths('root@c:/workspace/app# ls')).toEqual(['/workspace/app']);
|
||||
});
|
||||
|
||||
it('still finds rooted absolute paths, and never a relative path inside one', () => {
|
||||
expect(paths('sign-off from /mnt/raid1/x/refs/look_montage.png.')).toEqual(['/mnt/raid1/x/refs/look_montage.png']);
|
||||
// Unknown root: not linked at all (no `nix/store/…` cut out of it).
|
||||
|
||||
Reference in New Issue
Block a user