Repository navigation
Addresses #26184 - use configuration for pinned default - #27357
Conversation
|
Eric Amodio (@eamodio), thanks for your PR! By analyzing the history of the files in this pull request, we identified Johannes Rieken (@jrieken) and Erich Gamma (@egamma) to be potential reviewers. |
|
I have the feeling that this would be a lot more simple if that is implemented in the |
af5ddc3 to
14973d6
Compare
|
Johannes Rieken (@jrieken) I've re-worked this completely to move it down to hopefully the lowest level. So as per Benjamin Pasero (@bpasero) comments, if you pass |
|
Eric Amodio (@eamodio) this is a bad change as it can result in editors showing up as preview even though I think what Joh meant is to implement this behaviour only in the |
|
Benjamin Pasero (@bpasero) I guess I misunderstood your original comments. I thought the desire was to allow extensions to be able to fully control the pinned state regardless of If that isn't the case and |
|
Benjamin Pasero (@bpasero) Updated to honor |
|
Not sure how this should work Benjamin Pasero (@bpasero)? Now |
|
I do not really understand the need for introducing If we simply do not set pinning state when opening things, the default will be to open as preview unless this is disabled via user settings. In other words, I would let extensions opt-in to pinning (with the API we have today) but not set it by default. This should give the correct experience. Btw for webviews we should probably enforce pinning simply because the UI state in there is not preserved and it would be odd to loose the content so quickly. |
|
When I wasn't honoring Although honestly, I'd rather leave |
Benjamin Pasero (bpasero)
left a comment
There was a problem hiding this comment.
-1 for using undefined everywhere. +1 for not setting preview from extensions unless explicitly set.
|
Benjamin Pasero (@bpasero) do you want me to make the changes to take out |
|
Eric Amodio (@eamodio) yes, thanks |
00f4293 to
c01e0ce
Compare
|
Benjamin Pasero (@bpasero) I (hopefully) removed all the |
There was a problem hiding this comment.
Eric Amodio (@eamodio) Thanks, I think we can still reduce the number of changes.
| const group = this.ensureGroup(position, !options || !options.preserveFocus); | ||
| const pinned = !this.tabOptions.previewEditors || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty(); | ||
|
|
||
| let pinned = !this.tabOptions.previewEditors; |
There was a problem hiding this comment.
Can we leave this as:
const pinned = !this.tabOptions.previewEditors || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty();
I see now reason to change it and find the new code unreadable.
There was a problem hiding this comment.
This allows pinned: false to be honored explicitly rather than it falling through as a default.
There was a problem hiding this comment.
Eric Amodio (@eamodio) I am not sure we can do that, e.g. some code relies on the fact that dirty and untitled files open as pinned and never as preview which would replace them once another preview opens.
| let options: TextEditorOptions = null; | ||
| if (input && input.options) { | ||
| if (input.options.selection || input.options.viewState || input.options.forceOpen || input.options.revealIfVisible || input.options.revealIfOpened || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') { | ||
| if (input.options.selection || input.options.viewState || input.options.forceOpen || input.options.revealIfVisible || input.options.revealIfOpened || input.options.preserveFocus || input.options.pinned !== undefined || input.options.inactive || typeof input.options.index === 'number') { |
There was a problem hiding this comment.
Why are changes in this file needed, I suggest to leave it as it was?
There was a problem hiding this comment.
This allows pinned: false to be honored explicitly rather than it falling through as a default.
There was a problem hiding this comment.
Again, forcing pinned: false is not possible currently.
| options = { | ||
| preserveFocus: false, | ||
| pinned: true | ||
| pinned: undefined |
There was a problem hiding this comment.
Remove pinned: undefined
There was a problem hiding this comment.
Will do
|
|
||
| if (input.options.pinned) { | ||
| options.pinned = true; | ||
| if (input.options.pinned !== undefined) { |
There was a problem hiding this comment.
Leave as it was?
There was a problem hiding this comment.
Same as above
|
Benjamin Pasero (@bpasero) Any thoughts on the above? |
| if (options) { | ||
| editorOptions = { | ||
| pinned: !options.preview, | ||
| pinned: options.preview === undefined ? undefined : !options.preview, |
There was a problem hiding this comment.
I better like: typeof options.preview === 'boolean' ? !options.preview : undefined
| position: TypeConverters.fromViewColumn(columnOrOptions.viewColumn), | ||
| preserveFocus: columnOrOptions.preserveFocus, | ||
| pinned: columnOrOptions.preview === undefined ? true : !columnOrOptions.preview | ||
| pinned: columnOrOptions.preview === undefined ? undefined : !columnOrOptions.preview |
There was a problem hiding this comment.
I better like: typeof columnOrOptions.preview === 'boolean' ? ! columnOrOptions.preview : undefined
| const group = this.ensureGroup(position, !options || !options.preserveFocus); | ||
| const pinned = !this.tabOptions.previewEditors || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty(); | ||
|
|
||
| let pinned = !this.tabOptions.previewEditors; |
There was a problem hiding this comment.
Eric Amodio (@eamodio) I am not sure we can do that, e.g. some code relies on the fact that dirty and untitled files open as pinned and never as preview which would replace them once another preview opens.
| let options: TextEditorOptions = null; | ||
| if (input && input.options) { | ||
| if (input.options.selection || input.options.viewState || input.options.forceOpen || input.options.revealIfVisible || input.options.revealIfOpened || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') { | ||
| if (input.options.selection || input.options.viewState || input.options.forceOpen || input.options.revealIfVisible || input.options.revealIfOpened || input.options.preserveFocus || input.options.pinned !== undefined || input.options.inactive || typeof input.options.index === 'number') { |
There was a problem hiding this comment.
Again, forcing pinned: false is not possible currently.
|
Eric Amodio (@eamodio) what is the use case for forcing an editor to be not-pinned (= previewed)? Can you give me an example? |
|
Eric Amodio (@eamodio) in your demo today at lunch, you indicated that you wanted to open diff editors from the picker as preview and not pinned. But is that really an issue still if we do not set the pinned state by default from extensions? It seems to me the original request for |
|
Benjamin Pasero (@bpasero) Yeah, just being able to control it is enough. Though the main reason I wanted to plumb it all the way through was so that the final code could know the expressed desire of the extension, because it was passed as false, not left undefined. The only actual difference this would have is if this condition is met: |
|
Eric Amodio (@eamodio) thanks. I made some changes on top of yours. My argument is still that the pinned state cannot be overridden by the user if explicitly defined. Lots of stuff in the editor world depends on a dirty file being pinned for example (you cannot have a dirty file that shows up as preview). I went ahead and merged the PR because the original request seems addressed. |
Uses the configuration setting
workbench.editor.enablePreviewto provide a default ofpinnedif not explicitly passed. See #26184 (comment)Hopefully this is decent way of implementing this :)
/cc Johannes Rieken (@jrieken) Benjamin Pasero (@bpasero)