Skip to content

Autocomplete for extension search @-operators #53915

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

Merged
merged 19 commits into from
Jul 19, 2018

Conversation

JacksonKearl
Copy link
Contributor

@JacksonKearl JacksonKearl commented Jul 10, 2018

Closes #46333
This PR replaces the simple input box for extension search in the extension viewlet with a monaco editor with auto-complete support.
The auto-completion support is for pre-defined filters

@JacksonKearl JacksonKearl requested a review from ramya-rao-a July 10, 2018 00:45
@JacksonKearl JacksonKearl self-assigned this Jul 10, 2018
this.disposables.push(addStandardDisposableListener(this.searchBox, EventType.BLUR, () => removeClass(this.searchBox, 'synthetic-focus')));
this.monacoStyleContainer = append(header, $('.monaco-container'));
this.searchBox = this.instantiationService.createInstance(CodeEditorWidget, this.monacoStyleContainer, SEARCH_INPUT_OPTIONS, {});
this.placeholderText = append(this.monacoStyleContainer, $('.search-placeholder', null, 'Search Extensions in Marketplace'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text here should be localized

@@ -468,12 +510,17 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
return this.panels.reduce((count, view) => (<ExtensionsListView>view).count() + count, 0);
}

private onEscape(): void {
this.search('');
private autoComplete(query: string, position: number): { fullText: string, additionalText: string, overwrite: number }[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additionalText in the returned object doesnt seem to be used anywhere

label: item.fullText,
insertText: item.fullText,
overwriteBefore: item.overwrite,
sortText: item.fullText.indexOf(':') === -1 ? 'a' : item.fullText.indexOf('sort') !== -1 ? 'b' : 'c', // things with no colon; sorts; everything else
Copy link
Contributor

@ramya-rao-a ramya-rao-a Jul 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea for this sorting to show the pre-defined views first, followed by the most commonly used "@sort", and then the rest?
This makes tag and ext go to the very bottom. We can probably bring them up.

How about this:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make sense to me to have "sort:" and "category:" in the list, as a user would never want to select them. We could just change the sort algorithm to put "ext:" and "tag:" before "category:*"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, that works

const onKeyDownForList = onKeyDown.filter(() => this.count() > 0);
onKeyDownForList.filter(e => e.keyCode === KeyCode.Enter).on(this.onEnter, this, this.disposables);
const onKeyDownMonaco = chain(this.searchBox.onKeyDown);
onKeyDownMonaco.filter(e => e.keyCode === KeyCode.Tab).on(e => e.stopPropagation(), this, this.disposables);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pressing tab when the suggest widget is open should result in the selected suggestion being accepted. But this doesnt happen due to the above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this and below, I don't know of a good way to enable keys based on the suggest widget being open. the repl does something with contextkeys that's moderately complicated and doesn't actually work all that well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into what we do in the core editor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So core editor doesn't actually help much here I think, because in core editor they don't need to disable tabbing inside the editor. Unfortunately I cant find a way to get a trigger when the dropdown closes (the dropdown can close on click in addition to tab/esc/enter; we can listen to the keys, but not the click)


this.extensionsBox = append(this.root, $('.extensions'));

const onKeyDown = chain(domEvent(this.searchBox, 'keydown'))
.map(e => new StandardKeyboardEvent(e));
onKeyDown.filter(e => e.keyCode === KeyCode.Escape).on(this.onEscape, this, this.disposables);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are removing the binding of esc key to clearing of the text?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both because of the above regarding the escape needing to operate on the suggest widget, but also more generally is "esc" to clear input a common thing? We use it to get rid of modals, which technically also clears their input, but besides that we don't use it anywhere else in the program.

Copy link
Contributor Author

@JacksonKearl JacksonKearl Jul 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking around on Win10 and MacOS it turns out there are a fair number of places where Esc clears input (I've personally never known about that until now). But we still don't do in in Code, and browsers inputs don't do it by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we do it in settings search and keybindings. But still nowhere in the viewlets. I don't know what the best move is here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, lets not try to add this back. esc when suggest widget is open should remove the widget, otherwise esc need not do anything

}

private onEnter(): void {
(<ExtensionsListView>this.panels[0]).select();
(<ExtensionsListView>this.panels[0]).focus();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On enter, I see that we reach this line of code. But visually I dont see any focus changing. So what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Select also didn't do anything... this is dependent on #53616. I could bring those changes into this PR and close that one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, lets not try to do anything on Enter or Escape and focus on getting the tab to work

vertical: 'hidden'
},
ariaLabel: 'Search Extensions in Marketplace',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be localized as well.

let SEARCH_INPUT_OPTIONS: IEditorOptions =
{
fontSize: 13,

This comment was marked as resolved.

@JacksonKearl
Copy link
Contributor Author

Tab handling is fixed dependent on #54672.

@ramya-rao-a ramya-rao-a merged commit a0f07e3 into microsoft:master Jul 19, 2018
@ramya-rao-a
Copy link
Contributor

fyi @sandy081

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.

Improve discoverability of search filters in the extensions sidebar
2 participants