Skip to content

Add option to remove deleted text when copying#363

Open
WinslowJosiah wants to merge 1 commit intoexpressive-code:mainfrom
WinslowJosiah:remove-deleted-text-when-copying
Open

Add option to remove deleted text when copying#363
WinslowJosiah wants to merge 1 commit intoexpressive-code:mainfrom
WinslowJosiah:remove-deleted-text-when-copying

Conversation

@WinslowJosiah
Copy link

Fixes #314.

Adds a new removeDeletedTextWhenCopying option to remove text marked as "deleted" when copying. This option is false by default for backwards-compatibility.

If removeDeletedTextWhenCopying is true, any lines or segments of code that are marked as deleted using the plugin-text-markers plugin are not included when copied to the clipboard. This will also disallow the selection of said deleted lines or segments.

@netlify
Copy link

netlify bot commented Sep 26, 2025

Deploy Preview for expressive-code ready!

Name Link
🔨 Latest commit 3289492
🔍 Latest deploy log https://app.netlify.com/projects/expressive-code/deploys/68d6883b5034eb0008588e1c
😎 Deploy Preview https://deploy-preview-363--expressive-code.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

/* Disallow selection of deleted text */
user-select: none;
-webkit-user-select: none;
}`

Choose a reason for hiding this comment

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

Personally I think selecting deleted lines is sometimes pretty useful and would be very frustrating if it then doesn't work only on those lines. However, if I select all lines or at least multiple ones over different types of diffs, then I agree that such a feature would be useful, but way harder than just with CSS...

Copy link
Author

Choose a reason for hiding this comment

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

Sure, so perhaps this can be configurable as well?

Choose a reason for hiding this comment

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

Yeah, maybe we create some dedicated option for that, eg preventSelectingDeletedText or we might leave this out completely. I'm not sure how desired such a feature is, personally I would be more than happy enough with just the change when clicking the copy button.

@trueberryless
Copy link

In general, I really like the changes and this feature. Just a little nitpick regarding the naming of the option: maybe something like removeDiffDeletionsWhenCopying makes it clearer that this also only applies when the language of the code block is diff 🤔 It's somewhat difficult to make it clear but not too cluttered and long...

@WinslowJosiah
Copy link
Author

In general, I really like the changes and this feature. Just a little nitpick regarding the naming of the option: maybe something like removeDiffDeletionsWhenCopying makes it clearer that this also only applies when the language of the code block is diff 🤔 It's somewhat difficult to make it clear but not too cluttered and long...

Agreed, naming things is hard. But this doesn't only apply if the language of the block is diff, but also if any lines or sections are marked del with the Text & Line Markers plugin.

@trueberryless
Copy link

Agreed, naming things is hard. But this doesn't only apply if the language of the block is diff, but also if any lines or sections are marked del with the Text & Line Markers plugin.

Oh, thanks for clarifying, I totally missed this (I wonder how I could have missed that now 😅), then the names are really well suited 🙌

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.

Copying diff code block

2 participants