264 Commits

Author SHA1 Message Date
James Trew
b324469959 fix(pickers): sorting_strategy=asc stale result clearing (#3298)
With `sorting_strategy='ascending'`, the results buffer should never
have lines beyond the `max_results` count OR the number of available
results, whichever is smaller.

closes #3282
2024-09-23 02:02:08 +00:00
xudyang1
b5fd7f7ae0 fix(picker): nil check manager on toggle_selection (#3283)
Probably due to some async race condition, when typing fast, an error "attempt to index field 'manager' (a boolean value)" can be thrown if accidentally pressed <Tab> or <C-i> 

This is a temp fix for that.
2024-09-19 02:26:50 +00:00
Cameron Ring
f8985648e0 fix(picker): delete selection in disjointed finder results (#3266)
ipairs won't find find all results if entry_maker happens to return
nil for a line.
2024-09-12 00:32:38 +00:00
James Trew
bfcc7d5c6f fix(action.delete_buffer): improve behavior with splits (#3194)
Previously, when having window splits, with deleting a buffer involving
deleting a window, getting the jumplist for said deleted window would
result in an invalid jumplist. Trying to iterate over this invalid
jumplist would error out.

When there are split, there's no need to find a valid buffer to switch
the current window to (as the window is deleted). Instead, what's needed
is the updating of telescope's `picker.original_win_id` state. This is
important for when chaining buffer deletes (ie. closing many splits).

Also improve behavior when the "current" buffer is the only valid buffer
-> it will now open an empty buffer (same as when doing `:bdelete`).
2024-07-01 19:06:50 +00:00
James Trew
979bfa2c44 feat(builtin.buffers): enhance and bind delete_buffer action (#3145)
* feat(builtin.buffers): enhance and bind `delete_buffer` action

* change default bind and add docs

* [docgen] Update doc/telescope.txt
skip-checks: true

---------

Co-authored-by: Github Actions <actions@github>
2024-06-15 14:24:18 +00:00
Xavier Young
2df52609a1 feat(picker): allow appending original window <cWORD>, <cfile> and cursor line to prompt (#3134) 2024-05-27 23:02:25 +02:00
Christian Clason
bbdbb7593f fix: adapt to Nvim deprecations in 0.10 (#3109) 2024-05-17 14:39:12 +02:00
James Trew
52f500110b fix(picker): set current_line state earlier (#3052)
Sets the `current_line` global state earlier in the event loop rather
than in `get_results_completor`. This makes it safer to access
`current_line` earlier (eg. for building an entry).
2024-05-16 01:09:10 +00:00
Sofronie Cristian
1bb28df3cf feat(actions): support scrolling and selecting with the mouse (#2687)
* feat(scrolling and mouse support): support scrolling and selecting with the mouse

* fix ascending sorting_strategy mouse clicks

---------

Co-authored-by: James Trew <j.trew10@gmail.com>
2024-03-30 04:05:03 +00:00
0x7a7a
e9e01d6998 fix: select correct results row with sorting_strategy=ascending (#2986) 2024-03-15 20:16:51 +00:00
James Trew
dc1ea28cc2 Revert "fix(picker): actually set prompt win to text wrap (#2930)" (#2967)
This reverts commit 52190bd8f9.
2024-03-04 06:59:31 +01:00
Pou Yan
5f5fc3aa75 fix(picker): wrap vim.fn.expand cword in pcall to avoid Vim:E348 (#2961)
* fix(picker): wrap vim.fn.expand cword in pcall to avoid Vim:E348: No string under cursor

* run stylua

---------

Co-authored-by: James Trew <j.trew10@gmail.com>
2024-02-29 11:59:47 +00:00
James Trew
52190bd8f9 fix(picker): actually set prompt win to text wrap (#2930) 2024-02-24 15:12:39 +01:00
Kushashwa Ravi Shrimali
e9fd72bdb8 feat: only cache picker if the prompt is non empty; support last non-empty search instead (#2817) 2024-02-24 15:05:48 +01:00
James Trew
24778fd72f feat(picker): allow appending original window cword to prompt (#2878)
* feat(picker): allow appending original window cword to prompt

* add default mapping and document

* [docgen] Update doc/telescope.txt
skip-checks: true

* add mapping to README

also format README

* oops

* [docgen] Update doc/telescope.txt
skip-checks: true

---------

Co-authored-by: Github Actions <actions@github>
2024-01-20 02:38:27 +00:00
Simon Hauser
9cf58f438f fix(config)!: fallback to vim.o.winblend (#2861) 2024-01-18 11:45:02 +01:00
Dmitriy Kovalenko
0bf09d05ab feat: Support Line Column in file pickers (#2791)
This implements a experimental interface for allowing prompts like this `file.txt:3:4`. It is already enabled on default for `find_files` and `git_files`.

Be wary of breaking changes for the interface if you plan to manually enable it.
2024-01-09 09:35:26 +01:00
Sultanahamer
983460fb8c fix(picker): correctly apply wrap_results option (#2840)
Co-authored-by: sultanm <sultanm@sultanms-MacBook-Pro.local>
2024-01-03 14:03:36 +00:00
geril2207
18774ec792 fix: split commands while picker is open (#2784) 2023-11-16 02:12:34 +00:00
Simon Hauser
3a2579e203 fix: always reset prompt highlighting (#2739) 2023-10-23 09:45:01 +02:00
Munif Tanjim
84d53dfdbe feat(pickers): fully customizable layout (#2572) 2023-09-27 08:34:22 +02:00
James Trew
b543aaa2c9 fix: prompt_prefix leading whitespace normal mode cc (#2699)
* fix: `prompt_prefix` leading whitespace normal mode cc

* [docgen] Update doc/telescope.txt
skip-checks: true

---------

Co-authored-by: Github Actions <actions@github>
2023-09-16 03:40:00 +00:00
Sofronie Cristian
3d8e051c8c fix(internal.resume): dynamic_preview_title was not respected and title became static (#2696)
* fix(internal.resume): dynamic_preview_title was not respected and title became static

* run stylua
2023-09-09 23:33:01 +00:00
Sofronie Cristian
20a37e43bb fix(telescope.state.get_existing_prompts): it should only return keys 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
2023-09-04 18:05:59 +00:00
Hawtian Wang
3fae9c1e14 fix results win cursor for sorting_strategy descending (#2679)
* add an additional nvim_win_set_cursor

* Fix after filter

* remove redundant check

* use `redraw!` to replace ugly `nvim_win_set_cursor`

* redraw results win in `on_lines`

* use move instead of redraw

* fix

* keep both!

* fix!

* fix!
2023-09-02 22:07:57 +00:00
Marskey
dc192faceb feat: add searching indicator (#1717) (#2637) 2023-08-07 17:10:24 +00:00
Michael Henry
b6fccfb0f7 fix: preserve queued keys at picker launch (#2274) (#2625)
Ensure that any keystrokes that are queued at picker launch are
processed only after the picker's mode (`insert` or `normal`) has been
chosen, preserving their intended meaning.

Previously the picker's mode was set by simulating keystrokes via
`nvim_feedkeys(simulated_keypresses, "n")`. In the absence of queued
keystrokes, this works fine; but if the user is able to queue keystrokes
before the call to `nvim_feedkeys()`, those queued keystrokes are
processed before the simulated keystrokes that change the picker's mode.
Because of this unexpected ordering, the user's queued keystrokes may
appear to be ignored or may cause the picker to start in the wrong mode.

For example, consider the below normal-mode mapping:
```vim
:nnoremap <space>ff :Telescope find_files<CR>
```

Upon launching the picker via `<space>ff`, Neovim is already in normal
mode. To switch to insert mode in the picker, Telescope previously used
a call to `nvim_feedkeys("A", "n")`, simulating a keypress of `A` to
enter insert mode at the end of the current line.  This `A` would not be
processed until all previously queued user keystrokes have been
processed, causing issues.

In real-world use, problems occur when the user types `<space>ff`
followed quickly by characters intended as fuzzy match text.  This can
be demonstrated using `nvim_feedkeys()` as shown below.

```vim
:call nvim_feedkeys("\<space>ff" . "apple")
```

The user intended to search for `apple`, but the `a` is misinterpreted
as a request to enter insert mode at end of line, after which `pple` is
inserted; subsequently, Telescope's simulated `A` is then appended,
resulting in a search string of `ppleA`.

To ensure that Telescope's simulated keypresses are processed first, an
additional `i` flag is now passed to `nvim_feedkeys()`, causing the
simulated keypresses to be inserted at the start of the typeahead buffer
ahead of any user keystrokes.

Fixes #2274.
2023-07-29 20:48:13 +00:00
James Trew
1228f3b15c Revert "fix: preserve queued keys at picker launch (#2274)" (#2619)
* Revert "fix: preserve queued keys at picker launch (#2274) (#2618)"

This reverts commit f78d956901.

* [docgen] Update doc/telescope.txt
skip-checks: true

---------

Co-authored-by: Github Actions <actions@github>
2023-07-22 23:23:22 +00:00
Michael Henry
f78d956901 fix: preserve queued keys at picker launch (#2274) (#2618)
Ensure that any keystrokes that are queued at picker launch are processed only
after the picker's mode (`insert` or `normal`) has been chosen, preserving
their intended meaning.

Previously the picker's mode was set by simulating keystrokes via `feedkeys()`.
In the absence of queued keystrokes, this works fine; but if the user is able
to queue keystrokes before the call to `feedkeys()`, those queued keystrokes
are processed before the simulated keystrokes that change the picker's mode.
Because of this unexpected ordering, the user's queued keystrokes may appear to
be ignored or may cause the picker to start in the wrong mode.

For example, consider the below normal-mode mapping:
```vim
:nnoremap <space>ff :Telescope find_files<CR>
```

Upon launching the picker via `<space>ff`, Neovim is already in normal mode.
To switch to insert mode in the picker, Telescope previously used a call to
`feedkeys("A")`, simulating a keypress of `A` to enter insert mode at the end
of the current line.  This `A` will not be processed until all previously
queued user keystrokes have been processed, causing issues.

In real-world use, problems occur when the user types `<space>ff` followed
quickly by characters intended as fuzzy match text.  This can be demonstrated
using `feedkeys()` as shown below.

```vim
:call feedkeys("\<space>ff" . "apple")
```

The user intended to search for `apple`, but the `a` is mis-interpreted as a
request to enter insert mode at end of line, after which `pple` is inserted;
subsequently, Telescope's simulated `A` is then appended, resulting in a search
string of `ppleA`.

Using `:startinsert!` (to enter insert mode as if by `A`) or `:normal! $` (to
enter normal mode and move to end-of-line) avoids interfering with the user's
queued keys.

Fixes #2274.
2023-07-22 21:27:22 +00:00
Simon Hauser
991d5db624 refactor(mappings): use vim.keymap and remove __TelescopeKeymapStore (#2551) 2023-06-08 20:28:10 +02:00
Simon Hauser
eb95a31836 Revert "fix: correctly restore cursor position in original window (#2336)" (#2538)
This reverts commit 3f1b57908b.
2023-05-25 07:43:19 +02:00
Simon Hauser
ff8ed2351f fix: make sure that prompt_win is valid bevore closing it (#2533) 2023-05-24 22:15:59 +02:00
Simon Hauser
e943f93a6a fix: make sure buf is valid before updating highlighting (#2524) 2023-05-24 20:28:55 +02:00
cristiansofronie
3f1b57908b fix: correctly restore cursor position in original window (#2336) 2023-05-24 14:04:27 +02:00
Andrii Berezhynskyi
18b7479542 feat: add user autocmd TelescopeResumePost (#2433) 2023-05-24 11:41:59 +02:00
Simon Hauser
f48a7178ed Revert "fix: prefix color highlighting reset only on nvim 9.0 (#2492)" (#2510)
This reverts commit 41731e2f74.
2023-05-14 22:21:10 +02:00
Morten M. Neergaard
41731e2f74 fix: prefix color highlighting reset only on nvim 9.0 (#2492)
This fixes issue #2461
2023-05-14 22:00:59 +02:00
Andrii Berezhynskyi
10ebb30f0d fix: preview cycling and titles work after :Telescope resume (#2422) 2023-03-21 13:28:19 -04:00
Simon Hauser
a3f17d3baf fix: prefix color highlighting on nvim 0.9 (#2403) 2023-02-26 13:26:12 +01:00
Simon Hauser
3915d933dc fix: previewer = true (#2395) 2023-02-20 15:51:22 +01:00
Sultanahamer
3d8bd0a105 fix: wrap_results option breaking scrolling of results window (#2322) 2023-02-19 11:45:30 +01:00
Josa Gesell
e572c63c7d fix: execute autocmds correctly (#2375) 2023-02-19 10:27:15 +01:00
Aki
3e944f02ff fix(pickers): always redraw when screen is resized (#2140)
Due to regression from switching 
to lua autocmd api pickers
 were resized only once.
2022-08-24 09:04:15 +02:00
Fabian David Schmidt
28dc08f614 Revert "rfc: use extmarks for highlighting and carets (#2099)" (#2138)
This reverts commit 8d13f4ca8a.
2022-08-19 10:08:55 +02:00
Jeremy Saenz
8d13f4ca8a rfc: use extmarks for highlighting and carets (#2099)
* Starting to make some progress on extmarks for prefixes

* Finished up extmarks for multi-icons

* Cleaned up update_prefix calls, added display highlights

* remove highlight_one_row

* Remove TODOs

* stylua fixes

* fixes for luacheck

* Fixed whitespace to appease the stylua gods

* fixed a couple nits from pr

* Got tests passing with new highlighting functionality

* Apply suggestions from code review

Co-authored-by: Fabian David Schmidt <39233597+fdschmidt93@users.noreply.github.com>

Co-authored-by: Fabian David Schmidt <39233597+fdschmidt93@users.noreply.github.com>
2022-08-18 09:30:39 +02:00
Jonas Strittmatter
c6cd725bc0 chore: reduce log level to trace in pickers.lua (#2124) 2022-08-13 10:59:49 +02:00
Simon Hauser
4ab56d215a perf: limit scrolling size (#2059) 2022-07-12 09:46:51 +02:00
Simon Hauser
f838695459 chore: reformat with stylua 0.14.0 2022-07-07 08:27:46 +02:00
Fabian David Schmidt
ef9137d85c feat: refine with new_table 2022-07-01 18:13:25 +02:00
Simon Hauser
25b1bc8f17 feat: clear previewer if no item is selected (#2004) 2022-06-30 14:01:52 +02:00