Conversation
Restore legacy behavior where Insert After selectors can match when the target appears anywhere in a line (not just at the start), as long as only whitespace follows it. This fixes the case where selectors like '| ----- |' can match table separator rows like '| ------------- | -------- | ----- |' where the target appears at the end of the line. The matching logic now checks three scenarios in priority order: 1. Exact match (line equals target) 2. Prefix match (line starts with target + whitespace) 3. Substring match (target appears anywhere + whitespace after) This restores functionality that worked in v1.18.1 but was broken in newer versions. Fixes #970
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe pull request enhances the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant findInsertAfterIndex
participant LineEval as Line Evaluation
Caller->>findInsertAfterIndex: findInsertAfterIndex(lines, target)
loop For each line
findInsertAfterIndex->>LineEval: Check exact match or line starts with target
alt Exact/Prefix Match
LineEval-->>findInsertAfterIndex: Match found
findInsertAfterIndex->>findInsertAfterIndex: continue to next iteration
else No Exact/Prefix Match
LineEval->>LineEval: Search for target substring in line
alt Substring found
LineEval->>LineEval: Extract suffix after target
alt Suffix is whitespace-only
LineEval-->>findInsertAfterIndex: Valid match (return this index)
else Suffix has non-whitespace
LineEval->>LineEval: Store as fallback (first broad match)
LineEval-->>findInsertAfterIndex: Continue searching
end
else Substring not found
LineEval-->>findInsertAfterIndex: Continue to next line
end
end
end
findInsertAfterIndex-->>Caller: Return matched index or fallback index
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)src/formatters/capture-insert-after-linkcurrent.test.ts (1)
🔇 Additional comments (4)
Comment |
# [2.8.0](2.7.0...2.8.0) (2025-11-14) ### Bug Fixes * restore Insert After matching for table separator rows ([#983](#983)) ([1393e6a](1393e6a)), closes [#970](#970) * support frontmatter tags in getFieldValues filtering ([#980](#980)) ([c9de468](c9de468)), closes [#927](#927) ### Features * Add embed replacement option for link placement ([#984](#984)) ([06a77a3](06a77a3)), closes [#893](#893) * add provider-native model discovery ([#982](#982)) ([f195c06](f195c06)) * add textarea type for advanced script settings ([#981](#981)) ([dc9a650](dc9a650)) * add update modal settings for major releases only ([#985](#985)) ([d63f8c9](d63f8c9)), closes [#447](#447) * add write to top of file switch for capture to active file ([#986](#986)) ([5361e6c](5361e6c)), closes [#248](#248) [#248](#248)
|
🎉 This PR is included in version 2.8.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Problem
In QuickAdd v1.18.1, Insert After could match table separator rows when the selector appeared at the end of the line. For example, a selector like
| ----- |could successfully match a table separator row like:However, in newer versions (including v2.6.0), this functionality was broken. The matching logic only checked for:
This meant that selectors appearing at the end of lines (like in table separator rows) would fail to match, causing the error:
Solution
This PR restores the legacy matching behavior by adding substring matching support. The
findInsertAfterIndexfunction now checks three scenarios in priority order:The substring match restores the ability to match table separator rows where the selector appears at the end of the line, matching the behavior from v1.18.1.
Changes
findInsertAfterIndexincaptureChoiceFormatter.tsto support substring matchingTesting
Fixes #970
Summary by CodeRabbit