fix: keep a Bash( row out of the parenthesised path detector (#735)

A Bash( row holds a command, so its parentheses do not bound one spaced path:
`Bash(/tmp/a.out input.txt)` became a single link to a file that cannot exist and
lost master's `input.txt` link. The path tools keep linking a spaced name whole,
and a hard-wrapped Bash( row gets no spaced lookup either. Test rows from #734.

Co-Authored-By: DDT <141296842+Hugo-DDT@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainerandDDT committed 2026-11-04 16:57:10 +01:00
1 parent 2526fdb0d8
commit dc6f8d27e8
4 files changed
+48 -2

No files matched your search

+7
View File
@@ -343,6 +343,13 @@ describe('terminal link provider', () => {
expect(app.openLogViewerWindow).toHaveBeenCalledWith('/mnt/data/KoboeReader.conf', 's1');
});
it('never looks up a spaced name for a hard-wrapped Bash( row, which holds a command', async () => {
const { app, links } = linksOn(['Bash(/mnt/data/Kobo', ' eReader.conf)'], 1, 120);
await links[0].activate({}, links[0].text);
expect(app._registerExternalPreview).not.toHaveBeenCalled();
expect(app.openLogViewerWindow).toHaveBeenCalledWith('/mnt/data/KoboeReader.conf', 's1');
});
it('uses the original opener when both hard-wrap filenames are missing', async () => {
for (const row of [1, 2]) {
const { app, links } = linksOn(['Saved (/mnt/data/Kobo', ' eReader.conf).'], row, 120);
+24
View File
@@ -452,4 +452,28 @@ describe('terminal link provider with spaced paths', () => {
it('links nothing for an unlinkable spaced path', () => {
expect(linksFor('/etc/secret files/passwords.txt').links).toEqual([]);
});
// `Bash(` holds a command, so its parentheses bound no spaced path: master links the file
// (and the folder the executable sits in), never the whole command. The path tools do
// hold a path, a spaced filename included.
it.each([
['Bash(/tmp/a.out input.txt)', [{ path: 'input.txt' }]],
[
'Bash(/home/me/proj/build/mytool convert input.json)',
[{ path: '/home/me/proj/build/mytool', folder: true }, { path: 'input.json' }],
],
[
'Bash(/home/me/proj/target/release/app config.toml)',
[{ path: '/home/me/proj/target/release/app', folder: true }, { path: 'config.toml' }],
],
])('links %s the way master does, not as the whole command', (line, linked) => {
const found = findFilePathLinks(line).map(({ path, folder }) => (folder ? { path, folder } : { path }));
expect(found).toEqual(linked);
expect(found.map((hit) => hit.path)).not.toContain(line.slice(line.indexOf('(') + 1, -1));
});
it.each(['Read', 'Update', 'Write', 'Edit', 'NotBash'])('takes a spaced filename in %s( whole', (tool) => {
const path = '/mnt/data/Kobo/Kobo eReader.conf';
expect(paths(`${tool}(${path})`)).toEqual([path]);
});
});