mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 03:09:33 +01:00
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:
1 parent
2526fdb0d8
commit
dc6f8d27e8
4 files changed
+48
-2
No files matched your search
@@ -2215,6 +2215,7 @@ function findFilePathLinks(text) {
|
||||
// Parentheses bound an inline path just as a whole line bounds a standalone path.
|
||||
const parenthesised = /\(([^()\r\n]{1,1000})\)/g;
|
||||
while ((match = parenthesised.exec(line)) !== null) {
|
||||
if (opensBashCall(line, match.index)) continue;
|
||||
reserve(spacedFilePathOnLine(match[1], { parenthesised: true }), lineStart + match.index + 1);
|
||||
}
|
||||
lineStart += line.length + 1;
|
||||
@@ -2246,6 +2247,20 @@ function findFilePathLinks(text) {
|
||||
const SPACED_FILE_PATH_LABEL_PATTERN =
|
||||
/^(?:path|files?|saved (?:to|as)|wrote|written to|output|created|location|attachment):[ \t]*$/i;
|
||||
|
||||
/**
|
||||
* True when the `(` at `open` starts a `Bash(` tool row, which holds a command rather than
|
||||
* a path: `Bash(/tmp/a.out input.txt)` is a program and its argument, so the parentheses do
|
||||
* not bound one spaced path and the ordinary detectors keep the row. Only `Bash(`: the path
|
||||
* tools (`Read(`, `Update(`, `Write(`) do hold a path, spaces included.
|
||||
*
|
||||
* @param {string} text
|
||||
* @param {number} open Index of the `(`.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function opensBashCall(text, open) {
|
||||
return /(?:^|\W)Bash\($/.test(text.slice(Math.max(0, open - 5), open + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* A file path WITH SPACES on one line, or null.
|
||||
*
|
||||
@@ -2637,7 +2652,7 @@ function terminalPathLine(buffer, row, cols, maxRows) {
|
||||
if (kind === 'join') {
|
||||
const opening = text.lastIndexOf('(');
|
||||
const closing = next.text.indexOf(')');
|
||||
if (opening >= 0 && closing > 0) {
|
||||
if (opening >= 0 && closing > 0 && !opensBashCall(text, opening)) {
|
||||
const before = text.slice(opening + 1);
|
||||
const after = next.text.slice(0, closing).trimStart();
|
||||
const spaced = spacedFilePathOnLine(`${before} ${after}`, { parenthesised: true });
|
||||
|
||||
Reference in new issue
Block a user