Skip to content

Support delimiter insertion for "paste after" #771

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

Merged
merged 5 commits into from
Jun 16, 2022

Conversation

pokey
Copy link
Member

@pokey pokey commented Jun 15, 2022

Fixes #128
The main drawback here is that "paste after" inserts an extra undo stop. I think that's unavoidable until we have #559

Checklist

@pokey pokey force-pushed the pokey/paste-after-delimiters branch from 6b9f64f to d987ef5 Compare June 15, 2022 13:44
Base automatically changed from cleanupEditNew to main June 15, 2022 14:06
@pokey pokey force-pushed the pokey/paste-after-delimiters branch from d987ef5 to 933db4a Compare June 15, 2022 14:20
@@ -8,6 +8,7 @@ export type ActionType =
| "copyToClipboard"
| "cutToClipboard"
| "deselect"
| "editNew"
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this so that paste and insert snippet can use it; could be useful to map a spoken form at some point 🤷. Kinda like a fancy "change" that will insert delimiters if you give it a positional modifier

Copy link
Member

Choose a reason for hiding this comment

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

Then maybe we should just merge this with change and allowed that option?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my suggestion at meet-up, but the issue is that highlighting becomes a bit complex, as the targets will need to own a bit more. I'm not opposed to it, but maybe out of scope for this PR? We'll need to think a bit about giving targets more autonomy wrt highlighting

Copy link
Member

Choose a reason for hiding this comment

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

I think we can do that in a follow up pr

Copy link
Member

Choose a reason for hiding this comment

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

I mean we already have removal highlight range in the targets so we could just add content highlight range if we want.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think there is a fairly clean solution here that would also simplify the highlight graph component, but it's worth pairing on and I think out of scope

If you prefer for this PR I can just have the paste action keep its own EditNew object; that was my original solution

@@ -0,0 +1,82 @@
languageId: plaintext
command:
spokenForm: paste after line spun and after block look and before line spun
Copy link
Member Author

Choose a reason for hiding this comment

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

Shockingly, Cursorless handled this one with no problem, inserting the right delimiters and leaving cursors in the right spot 😯

Comment on lines +143 to +153
const clipboardActions: ActionType[] = context?.initialSnapshot
? ["pasteFromClipboard"]
: ["copyToClipboard", "cutToClipboard"];

const visibleRangeActions: ActionType[] = [
"foldRegion",
"unfoldRegion",
"scrollToBottom",
"scrollToCenter",
"scrollToTop",
];
Copy link
Member Author

Choose a reason for hiding this comment

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

These had rotted when we upgraded action names. I added explicit types to prevent that happening in the future

@pokey pokey requested a review from AndreasArvidsson June 15, 2022 20:56
@AndreasArvidsson AndreasArvidsson merged commit 58aff6f into main Jun 16, 2022
@AndreasArvidsson AndreasArvidsson deleted the pokey/paste-after-delimiters branch June 16, 2022 07:36
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.

Add "after" delimiter-adding support to "paste"
2 participants