Skip to content

[BUG] search_tui.rs next() and previous() Can Panic on Empty Results Edge Case #191

@xyz080125

Description

@xyz080125

Project

vgrep

Description

In search_tui.rs, the next() and previous() functions check self.results.is_empty() at the start but then access self.results.len() - 1. If results become empty between the check and access (in a theoretical multi-threaded scenario), this could cause underflow.

Error Message

Debug Logs

System Information

OS: Any
Rust Version: 1.75+

Screenshots

No response

Steps to Reproduce

  1. Open vgrep TUI
  2. Perform a search that returns results
  3. Navigate results while simultaneously triggering a new search that returns no results

Expected Behavior

Navigation should gracefully handle results changing during interaction

Actual Behavior

Potential race condition between results modification and navigation

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingideIssues related to IDEinvalidThis doesn't seem rightvgrep

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions