tpope / vim-rails

rails.vim: Ruby on Rails power tools
http://www.vim.org/scripts/script.php?script_id=1567
4.1k stars 383 forks source link

Autocomplete is greedier with nested controllers and models than with views #513

Closed heironimus closed 6 years ago

heironimus commented 6 years ago

Suppose I have the following directory structure:

app
  controllers
    users
      employees_controller.rb
      managers_controller.rb
  views
    users
      employees
        show.html.erb
      managers
        show.html.erb

When I type :Econtroller use<tab> it goes to :Econtroller users\employees not :Econtroller users\, which is what I expect and how :Eview works. For example, :Eview use<tab> goes to :Eview users\ and allows me to continue tabbing or typing.

:Emodel works similarly to :Econtroller

tl;dr :Eview autocompletion stops where I expect it to. :Econtroller and :Emodel go too far, IMHO.

heironimus commented 6 years ago

FWIW, I consider this a small nitpick in a superbly done extension. It works just like it would expect it to in a hundred other ways. Well done!

tpope commented 6 years ago

Did that intentionally a billion years ago because there are an order of magnitude views than other types, and I like being about to do :Eco emp<Tab> or even :Eco ue<Tab>. If that's too ambiguous, you can do :Eco u/e<Tab>. I'd encourage you to try doing one big tab complete rather than several smaller ones, and see how it feels.

heironimus commented 6 years ago

Make sense. The redundant view names also make it reasonable to treat them separately.

:Eco u/e<Tab> works great! 👍 for the big tab!

FWIW, Eco ue did not work as well as I had hoped in an example more complicated than the one above, but putting the slash in works great. Thanks!