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

quick open files in background #13925

Merged
merged 1 commit into from
Oct 21, 2016

Conversation

wprater
Copy link
Contributor

@wprater wprater commented Oct 18, 2016

  • allows one to continually open files while keeping quick open widget focused
  • uses the right modifier key to open in background
  • can open in split view if using the cmd trigger key

refs #13711

@mention-bot
Copy link

@wprater, thanks for your PR! By analyzing the history of the files in this pull request, we identified @egamma, @bpasero and @jrieken to be potential reviewers.

@msftclas
Copy link

Hi @wprater, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!
We will now validate the agreement and then real humans will evaluate your PR.

TTYL, MSBOT;

@jrieken
Copy link
Member

jrieken commented Oct 18, 2016

@wprater
Copy link
Contributor Author

wprater commented Oct 18, 2016

does TypeScript not support Object.assign? or do i need to alter a type def
file?
On Tue, Oct 18, 2016 at 1:03 AM Johannes Rieken notifications@github.com
wrote:

@wprater https://github.com/wprater There are compile errors -
https://ci.appveyor.com/project/VSCode/vscode/build/1.0.9419#L2861


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#13925 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAo1G12WTW6pxj_rayyJk2QB7iq8O--ks5q1H1PgaJpZM4KZeug
.

@bpasero
Copy link
Member

bpasero commented Oct 18, 2016

@wprater we have a assign method in https://github.com/Microsoft/vscode/blob/master/src/vs/base/common/objects.ts#L146 if you want to use that.

@wprater
Copy link
Contributor Author

wprater commented Oct 18, 2016

@wprater we have a assign method in https://github.com/Microsoft/vscode/blob/master/src/vs/base/common/objects.ts#L146 if you want to use that.

thanks. fixed up, but not sure why there are merge errors?

ps - on another note, I cannot seem to rid myself of this "ut8 dir path/file" test fixture, making it hard to rebase.

@@ -43,7 +43,8 @@ export interface IAutoFocus {

export enum Mode {
PREVIEW,
OPEN
OPEN,
OPEN_BEHIND
Copy link
Member

Choose a reason for hiding this comment

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

@wprater maybe better "OPEN_IN_BACKGROUND"?

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 almost chose that name, but I felt it was like a background job. Will change.

hide = this.model.runner.run(value, Mode.OPEN, context);
let mode = Mode.OPEN;

if (context.event instanceof KeyboardEvent) {
Copy link
Member

Choose a reason for hiding this comment

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

@wprater can we just send over a flag to indicate this mode from where we call this method with the arrow key right pressed? I think we already create the standard keyboard event there and do not need to create it again here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about we send over the StandardKeyboardEvent instead? I'd prefer this handler to account for biz logic as to which mode to use; elementSelected being called in multiple locations. StandardKeyboardEvent also has a browserEvent prop, so we can access the original event in this case.

Copy link
Member

Choose a reason for hiding this comment

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

Well you gotta be careful though because the event is being forwarded as context...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me take another look at this. I can pass in the mode, if need be, or revert to the original event while in the context?

if (mode === Mode.OPEN_BEHIND) {
opts = objects.assign(opts || {}, {
pinned: true,
revealIfVisible: true,
Copy link
Member

Choose a reason for hiding this comment

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

@wprater I think this option is a bit dangerous here because what it basically means is that the file will not be opened if it is visible in any other group. but I think the intent when sending files to open to the background is to open them in that group independent from other groups. I suggest to not set this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

} else {
objects.assign((<IResourceInput>input).options, opts);
Copy link
Member

Choose a reason for hiding this comment

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

@wprater carefull, options could be null within the resource input and I think this would break assign method.

Copy link
Member

Choose a reason for hiding this comment

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

@wprater also you seem to alter the way options used to be handled with IResourceInput. you are merging the options from getOptions() call into IResourceInput. we did not do that before though:

this.editorService.openEditor(<IResourceInput>input, sideBySide).done(null, errors.onUnexpectedError);

Copy link
Contributor Author

@wprater wprater Oct 18, 2016

Choose a reason for hiding this comment

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

fixed up. Object.assign handles null sources fine, will review your implementation (objects.assign) better.

if (context.event instanceof StandardKeyboardEvent) {
if (context.event.keyCode === KeyCode.RightArrow) {
if (event instanceof StandardKeyboardEvent) {
eventForContext = event.browserEvent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bpasero preserving the browser's event as the context here. will this work better? allows us to leave Mode logic in elementSelected.

@wprater wprater force-pushed the quickopen-in-background branch 2 times, most recently from 0a725b0 to afb3bd1 Compare October 20, 2016 00:41
@wprater
Copy link
Contributor Author

wprater commented Oct 20, 2016

@bpasero squashed the commit and fixed merge errors. looks the the CI system may need to be updated?

@bpasero
Copy link
Member

bpasero commented Oct 20, 2016

@wprater yes, the build errors are unrelated and should get resolved during the day today.

@bpasero
Copy link
Member

bpasero commented Oct 20, 2016

@wprater can you merge with master to get build fixes?

Are you done, should I review again?

@wprater
Copy link
Contributor Author

wprater commented Oct 20, 2016

I'll rebase and push up when I get home. otherwise I'm done.

On Wed, Oct 19, 2016, 22:55 Benjamin Pasero notifications@github.com
wrote:

@wprater https://github.com/wprater can you merge with master to get
build fixes?

Are you done, should I review again?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#13925 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAo1FEq1THMTmVVsvxYNRo6N2A6voEMks5q1wJsgaJpZM4KZeug
.

@wprater
Copy link
Contributor Author

wprater commented Oct 20, 2016

rebased and pushed, @bpasero

@bpasero bpasero dismissed their stale review October 20, 2016 14:06

new review

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

More feedback


let backgroundOpts;
if (mode === Mode.OPEN_IN_BACKGROUND) {
backgroundOpts = objects.assign({}, {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just { pinned: true, preserveFocus: true } ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

needs cleanup, was trying a different approach earlier. thanks.

if (mode === Mode.OPEN) {
const hideWidget = mode === Mode.OPEN;

let backgroundOpts;
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to move this into the other if check where we actually care about backgroundOpts. It is not being used in the scope otherwise.

let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0;
let opts = this.getOptions();
if (backgroundOpts) {
opts = objects.assign(opts || {}, backgroundOpts);
Copy link
Member

Choose a reason for hiding this comment

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

You cannot use objects.assign with the opts here because opts can be a real instance of EditorOptions, it might not just be an options bag. Maybe the better fix is to see if this.getOptions() could always return IEditorOptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any reason why we cannot merge the getOptions options with the (<IResourceInput>input).options? I know you previously mentioned it was not done.

If we can, it might be a nice approach to put the options logic in getOptions

    public getOptions(mode: Mode): EditorOptions {
        let opts = {};
        if (mode === Mode.OPEN_IN_BACKGROUND) {
            opts = { pinned: true, preserveFocus: true };
        }

        return EditorOptions.create(opts);
    }

for now I'll just

    public getOptions(): EditorOptions {
        return EditorOptions.create({});
    }

@@ -1115,6 +1115,9 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {

return true;
}
else if (mode === Mode.OPEN_IN_BACKGROUND) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we could always just return super.run(mode, context) here because the parent class does not handle PREVIEW anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good. in my other PR, Im refactored all this logic out, anyhow.

@bpasero
Copy link
Member

bpasero commented Oct 20, 2016

@wprater added more feedback, thanks 👍

@wprater
Copy link
Contributor Author

wprater commented Oct 20, 2016

np! check out the changes and you can merge, I squashed them.

not sure what is going on with the CI error tho?

@wprater wprater force-pushed the quickopen-in-background branch 2 times, most recently from 512ccda to e65a089 Compare October 20, 2016 23:24
- allows one to continually open files while keeping quick open widget focused
- uses the right modifier key to open in background
- can open in split view if using the cmd trigger key
@bpasero
Copy link
Member

bpasero commented Oct 21, 2016

@wprater pretty cool, let me merge and do a little bit of cleanup based on discussion. Thanks!

@bpasero bpasero merged commit 1d59084 into microsoft:master Oct 21, 2016
bpasero added a commit that referenced this pull request Oct 21, 2016
@wprater wprater deleted the quickopen-in-background branch October 21, 2016 07:58
@bpasero bpasero added this to the October 2016 milestone Oct 28, 2016
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 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.

None yet

5 participants