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

feat: collapse codeblocks in editing sessions #230005

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

joyceerhl
Copy link
Contributor

No description provided.

@joyceerhl joyceerhl self-assigned this Sep 27, 2024
@joyceerhl joyceerhl enabled auto-merge (squash) September 27, 2024 19:12
@vs-code-engineering vs-code-engineering bot added this to the October 2024 milestone Sep 27, 2024
@joyceerhl joyceerhl merged commit aa0b6bb into main Sep 27, 2024
7 checks passed
@joyceerhl joyceerhl deleted the dev/joyceerhl/coherent-scallop branch September 27, 2024 19:31
const codeblockModel = this.codeblocks[index];
if (codeblockModel.codemapperUri) {
const fileWidgetAnchor = $('.chat-codeblock');
this._register(this.instantiationService.createInstance(InlineAnchorWidget, fileWidgetAnchor, { uri: codeblockModel.codemapperUri }, { handleClick: (uri) => this.editorService.openEditor({ resource: uri }) }));
Copy link
Member

Choose a reason for hiding this comment

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

Seems wrong to render new content inside layout?

Copy link
Member

Choose a reason for hiding this comment

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

Don't these already open the file when you click? Do you just need to fix the data-href somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't these already open the file when you click?

I guess that's because these are <a /> tags in the existing use case, so I could set them up the same way here

Seems wrong to render new content inside layout?

We get new information about whether to change the presentation asynchronously, after the codeblock has already started rendering.

codemapperUri = undefined; // will be set async
public get uri() {
// here we must do a getter because the ref.object is rendered
// async and the uri might be undefined when it's read immediately
return ref.object.uri;
}
So I'm relying on firing onDidChange when that happens. Would it be better to add a render method instead that can change the presentation of the codeblock?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, either the whole Part should rerender, via hasSameContent returning false, or it should re-render itself and fire _onDidChangeHeight.

Copy link
Member

Choose a reason for hiding this comment

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

I don't really have an opinion whether we avoid using <a> entirely and make it more like a button, or use an <a> tag for the codeblock version, but it would be easier to follow if the two cases work the same.

Copy link
Member

Choose a reason for hiding this comment

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

I don't even follow why I have this layout method, since it's only called like this

markdownPart.addDisposable(markdownPart.onDidChangeHeight(() => {
			markdownPart.layout(this._currentLayoutWidth);

Seems like it could be simplified, I think it's leftover from my IChatContentPart refactoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants