-
Notifications
You must be signed in to change notification settings - Fork 31.9k
quick open files in background #13925
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
Conversation
Hi @wprater, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@wprater There are compile errors - https://ci.appveyor.com/project/VSCode/vscode/build/1.0.9419#L2861 |
does TypeScript not support Object.assign? or do i need to alter a type def
|
@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 |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
.
0a725b0
to
afb3bd1
Compare
@bpasero squashed the commit and fixed merge errors. looks the the CI system may need to be updated? |
@wprater yes, the build errors are unrelated and should get resolved during the day today. |
@wprater can you merge with master to get build fixes? Are you done, should I review again? |
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
|
afb3bd1
to
1f4020b
Compare
rebased and pushed, @bpasero |
There was a problem hiding this 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({}, { |
There was a problem hiding this comment.
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 }
??
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@wprater added more feedback, thanks 👍 |
np! check out the changes and you can merge, I squashed them. not sure what is going on with the CI error tho? |
512ccda
to
e65a089
Compare
- 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
e65a089
to
e8e3e35
Compare
@wprater pretty cool, let me merge and do a little bit of cleanup based on discussion. Thanks! |
refs #13711