Skip to content

Comments

[pull] master from junegunn:master#179

Merged
pull[bot] merged 2 commits intoadmariner:masterfrom
junegunn:master
Mar 26, 2025
Merged

[pull] master from junegunn:master#179
pull[bot] merged 2 commits intoadmariner:masterfrom
junegunn:master

Conversation

@pull
Copy link

@pull pull bot commented Mar 26, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Refactor terminal event handling and input processing logic in fzf to improve input and query management

Enhancements:

  • Restructure the event loop in terminal handling to simplify info printing and event processing
  • Modify input override and query change tracking logic to handle edge cases more robustly

Tests:

  • Add a new test case for search override query functionality in no-input mode

When 'search' and any action that modifies the query are in an action
chain, anything that comes later takes precedence.
@pull pull bot added the ⤵️ pull label Mar 26, 2025
@pull pull bot merged commit dac5b6f into admariner:master Mar 26, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 26, 2025

Reviewer's Guide by Sourcery

This pull request refactors the printing of info messages in terminal.go for better efficiency and correctness, fixes an input override issue, and adds a test case to verify search override functionality in test_core.rb.

Sequence diagram for printing info messages

sequenceDiagram
  participant Terminal
  Terminal->Terminal: uiMutex.Lock()
  Terminal->Terminal: mutex.Lock()
  loop For each key
    Terminal->Terminal: EventType(key)
    alt req == reqPrompt
      Terminal->Terminal: printPrompt()
      alt infoStyle == infoInline || infoStyle == infoInlineRight
        Terminal->Terminal: info = true
      end
    else req == reqInfo
      Terminal->Terminal: info = true
    else req == reqList
      Terminal->Terminal: printList()
      Terminal->Terminal: currentIndex()
      Terminal->Terminal: focusChanged
      alt focusChanged && focusedIndex >= 0 && track == trackCurrent
        Terminal->Terminal: track = trackDisabled
        Terminal->Terminal: info = true
      else focusChanged && track == trackNearest
        Terminal->Terminal: adjustTracked()
        Terminal->Terminal: info = true
      end
    end
  end
  alt info && !resizeIfNeeded()
    Terminal->Terminal: printInfo()
  end
  Terminal->Terminal: flush()
  Terminal->Terminal: mutex.Unlock()
  Terminal->Terminal: uiMutex.Unlock()
Loading

Updated class diagram for Terminal

classDiagram
  class Terminal {
    -input []rune
    -inputOverride []rune
    +Loop() error
    +printInfo()
    +resizeIfNeeded() bool
    +flush()
    +truncateQuery()
  }
  note for Terminal "inputOverride is now cleared when input changes"
Loading

File-Level Changes

Change Details Files
Refactors the printing of info messages to improve efficiency and ensure correct display after resizing.
  • Removes the RunOnce wrapper for printing info messages.
  • Introduces a boolean flag info to track whether info needs to be printed.
  • Conditionally prints info messages based on the info flag after processing events.
  • Calls printInfo only if resizeIfNeeded returns false.
src/terminal.go
Fixes a bug related to input override when the input hasn't changed.
  • Resets t.inputOverride to nil if the input string has not changed.
src/terminal.go
Adds a test case to verify search override query in no input mode.
  • Adds a new test case test_search_override_query_in_no_input_mode to test/test_core.rb.
  • The test case simulates a scenario where the query is overridden in no-input mode and verifies the correct behavior of the search.
test/test_core.rb

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant