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

allows undo/redo pasted images in chat #232777

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

justschen
Copy link
Contributor

can undo and redo pasted images

Screen.Recording.2024-10-31.at.5.03.48.PM.mov

@justschen justschen changed the title Justin/diglett allows undo/redo pasted images in chat Nov 1, 2024
@@ -89,6 +92,19 @@ export class PasteImageProvider implements DocumentPasteEditProvider {

widget.attachmentModel.addContext(imageContext);

this.undoRedoService.pushElement({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's see if we can move this into the BulkEditService. provideDocumentPasteEdits should not have any side effects, as this method may be called even if the edit is not actually applied yet

Here's what I'm thinking:

  • In our internal version of WorkspaceEdit, add a new edit type called something like ICustomEdit

  • ICustomEdit would be similar to the existing IWorkspaceUndoRedoElement. The main methods it would have are redo to apply the edit, and undo to undo it

  • Then update the bulk edit service to handle this new type of edit. This is will be the most complicated part as an ICustomEdit would need to work along side the normal text edits

@jrieken Does this sound like a reasonable proposal?

Two alternatives approaches :

  • If we'd prefer a more scoped fix, we could instead isolate this logic just to the copy paste controller so that DocumentPasteEdit can either return a WorkspaceEdit or a custom edit with undo and redo

  • We could add an explicit AddChatAttachment edit type and make the bulk edit service know how to handle that

Copy link
Member

@jrieken jrieken Nov 5, 2024

Choose a reason for hiding this comment

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

I think both make sense. Adding a special workspace edit might be a bit more involed but could be the right thing in the long run (it will enable more undo-able things) but it is also a bit weird that the DocumentPasteEdit#insertText is empty then (tho less weird than today where it all relies on side effects)

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