Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep initial sorting when typing query for oldfiles #3078

Open
albean opened this issue Apr 26, 2024 · 1 comment
Open

Keep initial sorting when typing query for oldfiles #3078

albean opened this issue Apr 26, 2024 · 1 comment
Labels
enhancement Enhancement to performance, inner workings or existent features

Comments

@albean
Copy link

albean commented Apr 26, 2024

Is your feature request related to a problem? Please describe.
I use require("telescope.builtin").oldfiles to navigate with the sort_mru option enabled. But as long as I start typing, files are resorted based on match, not by the initial sorting.

I've tried tiebreak workaround form #2539 but it doesnt make difference for my use case. I dont see how it would make it either.
The problem seems to be the resorting feature in query logic, which is useful when we don't care about initial sorting, which I don't, except foroldifiles

Describe the solution you'd like
I would like to pass some option to disable resorting while typing.

@albean albean added the enhancement Enhancement to performance, inner workings or existent features label Apr 26, 2024
@albean
Copy link
Author

albean commented Apr 26, 2024

I'm not particularly proud about this workaround, but it works perfectly for me:

function M.buffers()
  local builtin = require('telescope.builtin')

  local sorter = require("telescope.sorters").get_fzy_sorter()

  local fn = sorter.scoring_function

  sorter.scoring_function = function(_, prompt, line)
    local score = fn(_, prompt, line)

    return score > 0 and 1 or -1;
  end

  builtin.oldfiles({
    sorter = sorter,
    tiebreak = function(current_entry, existing_entry, _)
      return current_entry.index > existing_entry.index
    end,
  })
end

I'm not closing the issue in case you want to resolve it in more proper way since above solution feels like hacking more then configuring. Its fine by me.

As I said - default behaviour is useful in every case but this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features
Projects
None yet
Development

No branches or pull requests

1 participant