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

fix(telescope.state.get_existing_prompts): it should only return keys that are numbers #2684

Conversation

cristiansofronie
Copy link
Contributor

Description

telescope.state.get_existing_prompts currently returns all the keys from TelescopeGlobalState, this includes the 'global' key. This function is only used in Picker:close_existing_pickers where we iterate through the prompt_bufnr and call actions.close on each prompt_bufnr so it should only return keys that are numbers

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Run
:lua =require('telescope.state').get_existing_prompts()
When there are no pickers opened. It should return and empty table. With a picker present it should return the bufnr for that picker's prompt.

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code

@jamestrew
Copy link
Contributor

looks good. maybe we can rename the function get_existing_prompt_bufnrs to be explicit.

@cristiansofronie
Copy link
Contributor Author

I did the name change and also used pairs to only iterate once over the table since tbl_keys and tbl_filter each use a pairs internally and that is slower

@jamestrew jamestrew merged commit 20a37e4 into nvim-telescope:master Sep 4, 2023
Conni2461 pushed a commit that referenced this pull request Sep 5, 2023
… that are numbers (#2684)

* fix(telescope.state.get_existing_prompts): it should only return keys that are numbers

* Table keys not table values should be numbers

* Rename get_existing_prompts to get_existing_prompt_bufnrs and make the impl more efficient

(cherry picked from commit 20a37e4)
rameshsanth pushed a commit to rameshsanth/telescope.nvim that referenced this pull request Nov 17, 2023
… that are numbers (nvim-telescope#2684)

* fix(telescope.state.get_existing_prompts): it should only return keys that are numbers

* Table keys not table values should be numbers

* Rename get_existing_prompts to get_existing_prompt_bufnrs and make the impl more efficient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants