Skip to content

Conversation

@chhoumann
Copy link
Owner

@chhoumann chhoumann commented Dec 20, 2025

Summary

  • add per-choice blank-line mode (auto/skip/none) for Insert After
  • default auto skips blank lines only for ATX headings
  • update insert-after logic, tests, and docs/UI copy

Testing

  • bun run test

@vercel
Copy link

vercel bot commented Dec 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
quickadd Ready Ready Preview Dec 20, 2025 11:13am

@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2025

Walkthrough

The changes implement functionality to properly handle inserting content after lines followed by blank lines. When using "Insert After", the formatter now scans forward from the matched line to position the cursor after any trailing blank/whitespace lines, preserving spacing patterns.

Changes

Cohort / File(s) Summary
Documentation
docs/docs/Choices/CaptureChoice.md, src/gui/ChoiceBuilder/captureChoiceBuilder.ts
Added guidance explaining that Insert After skips trailing blank/whitespace lines and inserts after them to preserve spacing under headings. Includes a concrete example demonstrating the behavior.
Production logic
src/formatters/captureChoiceFormatter.ts
Added private helper method findInsertAfterPositionWithBlankLines to scan forward from a matched line and locate trailing blank lines. Updated insertAfterHandler to use this helper for position adjustment when not inserting at EOF.
Test suite
src/formatters/captureChoiceFormatter-frontmatter.test.ts
Added new test suite "CaptureChoiceFormatter insert after blank lines" with multiple test cases covering single/multiple blank lines, whitespace-only lines, no-follow scenarios, EOF cases, and CRLF content.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • findInsertAfterPositionWithBlankLines logic: Verify blank line detection, EOF handling, and scan limit behavior
  • insertAfterHandler integration: Confirm correct invocation and position adjustment logic
  • Test coverage: Review test cases for edge cases (EOF, CRLF, mixed whitespace)

Suggested labels

released

Poem

🐰 A blank line fix, so clean and neat,
Insert After now skips to greet,
Spacing preserved, headings aligned,
Your markdown's structure? Refined!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: implementing preservation of blank lines after insert-after matches.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #555 requirements: it handles blank lines after matched lines, preserves document structure with appropriate spacing, and supports multi-line blank and CRLF scenarios.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective of preserving blank lines after insert-after matches; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 555

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/docs/Choices/CaptureChoice.md (1)

60-70: LGTM: Documentation clearly explains the feature.

The explanation and example accurately demonstrate the blank-line-preservation behavior.

💡 Optional: Consider showing before/after states

The example could be slightly clearer by explicitly showing the before and after states:

 Example (Insert After `# H` with content `X`):
 
+Before:
+```markdown
+# H
+
+A
+```
+
+After:
 ```markdown
 # H
 
 X
 A

This makes it immediately clear where X was inserted.
</details>

</blockquote></details>
<details>
<summary>src/formatters/captureChoiceFormatter-frontmatter.test.ts (1)</summary><blockquote>

`181-309`: **LGTM: Comprehensive regression test suite.**

The tests thoroughly verify the blank-line-preservation behavior across multiple scenarios, including edge cases like CRLF content and EOF matches. The helper functions effectively reduce duplication.

Based on learnings, this provides excellent regression coverage for the bug fix.




<details>
<summary>💡 Optional: Consider adding a test for trailing blank lines at EOF</summary>

The current tests cover most edge cases, but you could add a test for when the matched line is followed by blank lines that extend to EOF:

```typescript
it('handles blank lines at EOF after the match', async () => {
  const { formatter, file } = createFormatter();
  const choice = createInsertAfterChoice('# H');
  const fileContent = '# H\n\n\n';

  const result = await formatter.formatContentWithFile(
    'X\n',
    choice,
    fileContent,
    file,
  );

  expect(result).toBe('# H\n\n\nX\n');
});

This would verify that the scanLimit logic correctly handles trailing blank lines.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fcd058f and 765bf7a.

📒 Files selected for processing (4)
  • docs/docs/Choices/CaptureChoice.md (1 hunks)
  • src/formatters/captureChoiceFormatter-frontmatter.test.ts (1 hunks)
  • src/formatters/captureChoiceFormatter.ts (2 hunks)
  • src/gui/ChoiceBuilder/captureChoiceBuilder.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Source code lives in src/: core logic under engine/, services/, and utils/; Svelte UI in src/gui; shared types in src/types; settings entry in src/quickAddSettingsTab.ts

Files:

  • src/gui/ChoiceBuilder/captureChoiceBuilder.ts
  • src/formatters/captureChoiceFormatter-frontmatter.test.ts
  • src/formatters/captureChoiceFormatter.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.{ts,tsx}: Biome enforces tab indentation (width 2), LF endings, and an 80-character line guide; align editor settings
Use camelCase for variables and functions
Prefer type-only imports in TypeScript files
Route logging through the logger utilities for consistent output
Structure production code so Obsidian dependencies are injected behind interfaces; unit tests target pure logic and swap in adapters or tests/obsidian-stub.ts

Files:

  • src/gui/ChoiceBuilder/captureChoiceBuilder.ts
  • src/formatters/captureChoiceFormatter-frontmatter.test.ts
  • src/formatters/captureChoiceFormatter.ts
src/**/*.{ts,tsx,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

Use PascalCase for classes and Svelte components

Files:

  • src/gui/ChoiceBuilder/captureChoiceBuilder.ts
  • src/formatters/captureChoiceFormatter-frontmatter.test.ts
  • src/formatters/captureChoiceFormatter.ts
docs/**/*

📄 CodeRabbit inference engine (AGENTS.md)

Keep user-facing docs in docs/ directory

Files:

  • docs/docs/Choices/CaptureChoice.md
🧠 Learnings (1)
📚 Learning: 2025-12-09T21:20:52.425Z
Learnt from: CR
Repo: chhoumann/quickadd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T21:20:52.425Z
Learning: Applies to tests/**/*.{ts,tsx} : Add regression coverage for bug fixes

Applied to files:

  • src/formatters/captureChoiceFormatter-frontmatter.test.ts
🧬 Code graph analysis (1)
src/formatters/captureChoiceFormatter-frontmatter.test.ts (3)
src/formatters/captureChoiceFormatter.ts (1)
  • CaptureChoiceFormatter (16-399)
src/types/choices/ICaptureChoice.ts (1)
  • ICaptureChoice (5-46)
src/services/choiceService.ts (1)
  • createChoice (30-34)
🔇 Additional comments (3)
src/gui/ChoiceBuilder/captureChoiceBuilder.ts (1)

410-413: LGTM: Clear user-facing guidance.

The updated description accurately explains the blank-line-preservation behavior and provides helpful context about using headings as targets.

src/formatters/captureChoiceFormatter.ts (2)

201-224: LGTM: Well-implemented blank-line-scanning logic.

The helper correctly:

  • Scans forward from the matched line to find contiguous blank lines
  • Handles EOF edge cases by excluding the trailing empty string from split("\n") when the body ends with a newline
  • Preserves existing behavior when no blank lines follow

259-265: LGTM: Correct integration of blank-line handling.

The helper is correctly called only when !insertAtEnd, preserving the existing section-end logic when insertAtEnd is enabled.

@chhoumann chhoumann merged commit 818c036 into master Dec 20, 2025
4 checks passed
@chhoumann chhoumann deleted the 555 branch December 20, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants