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

Fixes #69843 - Navigate File Search History #88307

Closed
wants to merge 1 commit into from

Conversation

alpalla
Copy link
Contributor

@alpalla alpalla commented Jan 8, 2020

This pull request implements a possible solution to issue #69843. Note that this is simply an idea for a solution, I made some assumptions that may not be true for other users. I mention these points in the "Doubts/Talking points" section of this PR.

Summary of the feature request

It was requested that when searching for a file (through Cmd+p or Ctrl+p) it should be possible to go back (and forward) through the inputed filenames (such as is possible in the Atom text editor).

Overview of the solution

I added an array to QuickOpenController to store the lastSubmittedInputValue. The value is stored each time onOK() executes.
The array always begins and ends with an empty string '' so that when the user goes beyond the very first submitted input value, the QuickOpenWidget search bar is cleared (same reasoning for when the user goes too far forward in the history).
The navigateInputHistory method I added to the QuickOpenController is the code that handles navigating the array.

How to test

To test this out, open a folder with vscode and add a custom keybinding in User/keybindings.json similar to:

[
	{
	"key": "cmd+z",
	"command": "navigateInputHistory",
	"when": "inQuickOpen",
	"args": "backwardInInputHistory"
	},
	{
	"key": "cmd+y",
	"command": "navigateInputHistory",
	"when": "inQuickOpen",
	"args": "forwardInInputHistory"
	}
]

You can then:

  • search for a couple of files and hit enter to open up each of those files
  • go back to searching for files with Cmd+p
  • hit Cmd+z (and later Cmd+y) to ensure that the keybindings correctly go back and forth in the list of filenames you previously submitted and hit enter with.

Doubts/Talking points

  1. I was not clear on the HistoryInputBox that should have been hooked up to quick open that was mention by @roblourens here, this solution is what I came up with in the meanwhile.
  2. I tried using this feature in Atom and my understanding is that Atom does something more complex than simply going back through the history of submitted filenames. Is this solution too simple with respect to what Atom does?
  3. What about duplicates? That is, if I enter filename "A", then hit enter, then search for "A" again and hit enter again. The way this solution is implemented, "A" would show up twice in a row in the history which is kind of ugly.
  4. I could not get alt+up/down to work as a shortcut on my machine, that just kept navigating me through the list of found files.
  5. Should this be a default shortcut?

…ber variable and method to navigate the file search history in the QuickOpenController. The inputed file names are stored in an array, which always has a blank string at the beginning and at the end. This serves to implement the functionality in which a user goes past the end of the history, in which case the QuickOpenWidget should have no previously inputed filename, thus being blank (similar reasoning when going forward in the history)
@bpasero bpasero added this to the Backlog milestone Jan 9, 2020
@bpasero
Copy link
Member

bpasero commented Jan 9, 2020

Thanks for the PR, but please hold on to making more changes. Given #69955 I am planning to refactor quick open quite a bit. Supporting a history of inputs is something that probably needs to go into the quick input widget: src/vs/workbench/browser/parts/quickinput/quickInput.ts

//cc @chrmarti

@bpasero
Copy link
Member

bpasero commented Mar 20, 2020

@alpalla quick open is moving into a new world leveraging quick input facilities (see

export class QuickAccessController extends Disposable implements IQuickAccessController {
). I feel this kind of support needs to somehow go into the quick input widget itself and be there as a setting that pickers can enable (because we probably do not want this for every picker).

I suggest to coordinate this with the widget owner @chrmarti . Closing this PR.

@bpasero bpasero closed this Mar 20, 2020
@github-actions github-actions bot locked and limited conversation to collaborators May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants