Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mitsuhiko/insta
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.46.0
Choose a base ref
...
head repository: mitsuhiko/insta
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.46.1
Choose a head ref
  • 2 commits
  • 5 files changed
  • 2 contributors

Commits on Jan 8, 2026

  1. Fix inline snapshot corruption with multiple snapshots in with_settin…

    …gs! (#858)
    
    ## Summary
    
    Fixes #857
    
    When `find_snapshot_macro(line)` was called for a line inside a macro
    like `with_settings!`, the `scan_nested_macros` function would scan all
    nested tokens and find all `@"..."` patterns. Since
    `try_extract_snapshot` always overwrote the result, the **last**
    snapshot found would win regardless of which line we were searching for.
    
    This caused:
    1. All searches for lines inside `with_settings!` returned the same
    (last) snapshot position
    2. The duplicate detection logic discarded all but the first pending
    snapshot
    3. The first pending snapshot's content got written to the last
    snapshot's position
    
    **Example from the issue:**
    ```rust
    insta::with_settings!({filters => vec![...]}, {
        assert_snapshot!(":12345\n\nabc", @"");  // line 10
        assert_snapshot!(":12345\n\nabc", @"");  // line 11
        assert_snapshot!("", @"");               // line 12
        assert_snapshot!("", @"");               // line 13 - incorrectly got content from line 10!
    });
    ```
    
    ## The Fix
    
    Instead of filtering during scanning, we now:
    1. **Collect all snapshots** with their macro boundaries (start/end
    line)
    2. **Filter at the end** to find the one whose macro span contains the
    target line
    
    This approach is more general because:
    - The scanning logic collects everything uniformly
    - The line-matching logic is centralized in one place
    - It works at any nesting depth
    
    ## Test plan
    
    - [x] All existing tests pass (111 tests)
    - [x] Added regression test
    `test_find_snapshot_macro_multiple_in_with_settings`
    - [x] Manually verified with the reproduction case from the issue
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-authored-by: Claude <[email protected]>
    max-sixty and claude authored Jan 8, 2026
    Configuration menu
    Copy the full SHA
    822f404 View commit details
    Browse the repository at this point in the history

Commits on Jan 15, 2026

  1. Release 1.46.1 (#859)

    ## Summary
    
    - Fix inline snapshot corruption when multiple snapshots appear inside
    `with_settings!` macro #858
    
    ## Test plan
    
    - [x] All tests pass
    - [x] Pre-commit passes
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    > _This was written by Claude Code on behalf of max-sixty_
    
    Co-authored-by: Claude <[email protected]>
    max-sixty and claude authored Jan 15, 2026
    Configuration menu
    Copy the full SHA
    8a5b775 View commit details
    Browse the repository at this point in the history
Loading