earshinov / vscode-filter-lines

Extension for Visual Studio Code allowing to quickly find all lines matching a string or regular expression
https://marketplace.visualstudio.com/items?itemName=earshinov.filter-lines
MIT License
14 stars 3 forks source link

Filtering history #32

Open dstd opened 6 months ago

dstd commented 6 months ago

Please add a history of filter queries. It's a really useful feature.

earshinov commented 6 months ago

Hello @dstd ,

Thank for taking time to submit this feature request.

Having search history definitely makes sense. VS Code itself has both for the simple "Find" and "Search: Find in files". The extension already has a limited support for it: you can set "filterlines.preserveSearch": true in your user settings and the extension will store the last value searched for.

I cannot support multiple values in search history for the moment as VS Code extension API doesn't have UI elements that would be required, see for example https://github.com/microsoft/vscode/issues/35785.

1. The InputBox widget does not provide completions, a dropdown, or even a possibility to track user's keyboard input, such as Alt-↑↓ keys, which the extension could employ to support navigation through search history.

2. The QuickPick widget does provide a dropdown, and with a quick hack it is even possible to allow for arbitrary values in addition to the items in the dropdown (the search history), e.g.

const box = vscode.window.createQuickPick();
box.title = prompt;
box.onDidChangeValue((value) => {
  box.items = [{ label: value }];
});
return new Promise(resolve => {
  box.show();
  box.onDidAccept(() => resolve(box.value));
  box.onDidHide(() => resolve(undefined));
});

However, it looks ugly:

image

3. Technically, it is possible to devise our own UI (as in the Color Picker extension, for example), but it will involve kicking off a separate Electron process with a separate app / UI it, which is far too much for the task at hand.

Overall, I don't see any feasible options :-( I am going to leave this issue open for tracking and in case someone comes up one day with an acceptable solution.