mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-02 16:59:32 +01:00
fix: apply the review items for #687 at merge
- constants.js:2296,2301 spacedFilePathOnLine: refuse a first word ending in `$` and an earlier word with no letter or digit (other than a bare `-`), so a shell prompt showing an absolute working directory (`/mnt/c/proj ❯ code notes.md`, `/home/me/proj$ cat notes.md`) keeps master's links; the six rows from the review are pinned, plus OneDrive, `Program Files (x86)` and `Docs - Copy` still linking whole. - constants.js:2312: the leading strip is now `/^(?:~?\/|(?:\.\.?\/)+)/`, so `Saved to: ../My Docs/plan.md` links whole; an interior `..` still links nothing. Tests for the detector and the terminal provider. - app.js:3032 _linkifyFilePaths: carry any leading bold label and let spacedFilePathOnLine() judge it, and give a text node that follows another inline element a placeholder word, so `**Note:** /home/me/proj/out report.pdf` and ``Use `--config` /home/me/proj/cfg data.json`` split as in the terminal; a spaced path inside inline code still links whole. The now-unused label-pattern guard is gone. - JSDoc (findFilePathLinks, SPACED_FILE_PATH_LABEL_PATTERN, spacedFilePathOnLine) and the spaced-path paragraph in docs/architecture-invariants.md updated to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
df9f93d3ee
commit
e52cc60c7c
5 files changed
+91
-18
No files matched your search
+13
-10
@@ -3015,23 +3015,26 @@ class CodemanApp {
|
||||
// invalidates the traversal.
|
||||
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
||||
const targets = [];
|
||||
// Same promise as the guard above: a stale constants.js without the label
|
||||
// pattern only loses the carried label, it never throws.
|
||||
const labelPattern = typeof SPACED_FILE_PATH_LABEL_PATTERN !== 'undefined' ? SPACED_FILE_PATH_LABEL_PATTERN : null;
|
||||
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
||||
if (node.parentElement?.closest('a')) continue;
|
||||
// Markdown puts **Saved to:** in a separate <strong> node. Carry only
|
||||
// an explicit path label that starts its line into detection; never
|
||||
// arbitrary prose or a label from another block. Chat renders with
|
||||
// Markdown puts **Saved to:** in a separate <strong> node. Carry a bold
|
||||
// label that starts its line into detection and let spacedFilePathOnLine()
|
||||
// judge it, as it does the same line in the terminal (`Note:` is not a
|
||||
// path label); never a label from another block. Chat renders with
|
||||
// `breaks: true`, so a later line of a paragraph starts after a <br>.
|
||||
// The label itself stays untouched.
|
||||
// A text node after any other inline element (`Use <code>--config</code>
|
||||
// /a/b c.json`) starts mid-line, so a placeholder word stands in for what
|
||||
// precedes it. The label itself stays untouched.
|
||||
const label = node.previousSibling;
|
||||
let beforeLabel = label?.previousSibling;
|
||||
if (beforeLabel?.nodeType === 3 && !beforeLabel.nodeValue.trim()) beforeLabel = beforeLabel.previousSibling;
|
||||
const labelText = label?.nodeName === 'STRONG' ? label.textContent : '';
|
||||
const leadingLabel =
|
||||
/^(?:P|LI)$/.test(node.parentElement?.tagName || '') && (!beforeLabel || beforeLabel.nodeName === 'BR');
|
||||
const prefix = leadingLabel && labelPattern?.test(labelText) ? `${labelText} ` : '';
|
||||
label?.nodeName === 'STRONG' &&
|
||||
/^(?:P|LI)$/.test(node.parentElement?.tagName || '') &&
|
||||
(!beforeLabel || beforeLabel.nodeName === 'BR');
|
||||
let prefix = '';
|
||||
if (leadingLabel) prefix = `${label.textContent} `;
|
||||
else if (label?.nodeType === 1 && label.nodeName !== 'BR') prefix = 'x ';
|
||||
const found = findFilePathLinks(prefix + (node.nodeValue || ''))
|
||||
.filter((hit) => hit.index >= prefix.length)
|
||||
.map((hit) => ({ ...hit, index: hit.index - prefix.length }));
|
||||
|
||||
Reference in new issue
Block a user