Skip to content

[Design review] New patterns validated by a real hardtime.nvim feature request: f/t search-motion swap detection #304

Description

@kamegoro

Summary

hardtime.nvim's issue tracker (issue #10, a real third-party user asking for almost exactly tobira's premise) proposed detecting: f<char>h -> suggest t<char> (search-until instead of search-to-then-back-up-one), and its mirror F<char>l -> suggest T<char>. Confirmed via reading lua/tobira/core/patterns.lua's f_repeat handling that no such swap detection currently exists — the only existing f/t-related pattern is f_repeat (repeated f<char> -> suggests ;), which is unrelated.

Why this needs review before implementation

Needs a threshold/confidence decision: is f<char> immediately followed by h (or F<char> followed by l) reliable enough evidence of "the user meant to stop one character earlier" to suggest a command swap, or is this too easily confused with an unrelated, coincidental h/l press right after a search? Also needs a decision on the reverse direction (mentioned by a follow-up commenter on the same hardtime issue): t<char> followed by l -> suggest f<char>, T<char> followed by h -> suggest F<char> (the inverse correction).

Detectability note

Fully keystroke-based — the two keys are directly adjacent in the keystroke stream, no buffer/window state needed.

Relevant files

  • lua/tobira/core/patterns.lua (near the existing f_repeat handling)
  • lua/tobira/commands.lua

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions