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

Update string truncation behavior #125

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

j-f1
Copy link

@j-f1 j-f1 commented Oct 9, 2020

This should look visually similar, but selecting and copying a truncated string will now copy the entire string (excluding the “…”), even the portion that is not visible.

I have also changed the ellipsis from the standard ellipsis character (), which can easily be missed, to a more obvious ••• rendered in black so it is clearly not part of the string.

Screenshot_2020-10-09 15 19 25

@j-f1
Copy link
Author

j-f1 commented Nov 29, 2022

Would it be possible to get this merged? It annoys me that it’s really hard to copy out long strings from notebooks.

@mootari
Copy link
Member

mootari commented Nov 29, 2022

I believe the ellipsis is not only a visual aid for long strings, but also avoids rendering excessively large strings in the DOM. Under that premise you'd have to pick a different strategy. Some suggestions:

  • replace the ellipsis with its masked content on click
  • allow truncated strings to be expanded (like we do for arrays and objects), revealing the entire string line-wrapped
  • detect copy events, determine whether the ellipsis text node is in the selection range, and replace it with the actual content
  • add an explicit copy button (e.g. on hover)

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.

2 participants