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

Forwards the isUndoing/isRedoing flags to the extension host. #124996

Merged
merged 1 commit into from
Jul 7, 2021

Conversation

hediet
Copy link
Member

@hediet hediet commented May 31, 2021

This PR addresses #120617.

No time pressure, this can wait.

@hediet hediet requested a review from jrieken May 31, 2021 18:51
@jrieken jrieken added this to the June 2021 milestone May 31, 2021
@jrieken
Copy link
Member

jrieken commented Jun 1, 2021

This should maybe done like TextEditorSelectionChangeKind, e.g have a kind-property on the event which classifies how the event was triggered

@hediet
Copy link
Member Author

hediet commented Jun 1, 2021

I thought of some TextEditorSelectionChangeKind too, but that might give the wrong impression that the enum is exhaustive.

enum TextEditorSelectionChangeKind {
    Undo,
    Redo,
    Other // or unknown
}

Then users can check for if (event.changeKind === TextEditorSelectionChangeKind.Other).
If there ever will be the variant typeInput (or remoteEdit), that would break extensions.
Another boolean flag isTypeInput: boolean would not break extensions though, as they cannot really depend on its non-presence.

Alternatively, the enum has no Other variant but is stored in a field that can be undefined.
But then users could check if that field is undefined.

@jrieken
Copy link
Member

jrieken commented Jun 1, 2021

Alternatively, the enum has no Other variant but is stored in a field that can be undefined.

That's how TextEditorSelectionChangeEvent.kind works - it can be undefined or set to a known state. The advantage of the enum is that it prohibits invalid states, e.g it doesn't allow for { isUndoing: true, isRedoing: true }

@hediet hediet force-pushed the hediet/isUndoRedo branch from 047a50c to b81aebe Compare June 1, 2021 15:46
@jrieken jrieken removed this from the June 2021 milestone Jun 28, 2021
@hediet hediet merged commit 556f74a into main Jul 7, 2021
@hediet hediet deleted the hediet/isUndoRedo branch July 7, 2021 15:57
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2021
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.

API Request: onDidChangeTextDocument - differentiate between user input and redo/undo
2 participants