Skip to content

notebookControllerAffinityHidden proposal to allow for hiding of notebook controllers per document#161145

Merged
IanMatthewHuff merged 4 commits intomicrosoft:mainfrom
IanMatthewHuff:dev/ianhu/controllerAffinityHidden
Sep 20, 2022
Merged

notebookControllerAffinityHidden proposal to allow for hiding of notebook controllers per document#161145
IanMatthewHuff merged 4 commits intomicrosoft:mainfrom
IanMatthewHuff:dev/ianhu/controllerAffinityHidden

Conversation

@IanMatthewHuff
Copy link
Copy Markdown
Member


declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/161144
export enum NotebookControllerAffinityExtended {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was a slight bit unsure on the best way to just extend an enum, didn't see an easy "typescripty" way to add in the new value. So I went with just adding a new extended type and updating the controller function to take either type. Would love to know if there is a better way to do this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fair - there are limits to what we can do with TypeScript. On a nit-note: in such cases we usually use the 2 suffix, not Extended, so NotebookControllerAffinity2 might be a bit better

suggestions.push(all[0]);
}
return { all, selected, suggestions };
return { all, selected, suggestions, hidden };
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Instead of filtering all at this point it seemed to match the current usage to keep all as all, then just provide hidden to indicate the kernels marked as hidden.

Copy link
Copy Markdown
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

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

looking good at first sight, make sure to either enforce the proposal tho (or fast track to finalization directly)

@IanMatthewHuff
Copy link
Copy Markdown
Member Author

Updates:
NotebookControllerAffinityExtended => NotebookControllerAffinity2

Also added in the proposed API guard. The guard looked a tiny bit different since I was only adding on an enum value, so instead of guarding the function I just guarded against the new enum value.

Tested (extension using the new Hidden value wo/ specifying the proposedAPI):
image

Tested (extension not using the new Hidden value wo/ specifying the proposedAPI, to make sure I'm not erroring for someone using the normal API):
image

Tested (extension using the new Hidden value and specifying the proposedAPI):
image

All looks good from my understanding. Only error thrown when trying to pass in the Hidden value wo/ specifying the API.

@IanMatthewHuff IanMatthewHuff marked this pull request as ready for review September 19, 2022 18:33
@vscodenpa vscodenpa added this to the September 2022 milestone Sep 19, 2022
Copy link
Copy Markdown
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

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

Looking good.

Going forward with the API we need

  • jsdoc for all the things
  • reconsider the -1 value, maybe one in sequence is fine too
  • ensure the name Hidden is "good"

@IanMatthewHuff IanMatthewHuff merged commit 2872294 into microsoft:main Sep 20, 2022
@IanMatthewHuff IanMatthewHuff deleted the dev/ianhu/controllerAffinityHidden branch September 20, 2022 15:15
@IanMatthewHuff IanMatthewHuff restored the dev/ianhu/controllerAffinityHidden branch September 26, 2022 17:52
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2022
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.

3 participants