Skip to content

Conversation

webpro
Copy link

@webpro webpro commented Jun 23, 2025

In my opinion, the newline should be considered to have length 1. It's not zero-width like other control characters.

@fabiospampinato
Copy link
Owner

In what context does it occupy one space? 🤔

In the terminal it seems to occupy zero space:

Screen Shot 2025-08-22 at 12 24 01

Maybe we could make this customizable if you need that in a different context?

@webpro
Copy link
Author

webpro commented Aug 23, 2025

When truncating/splitting a string, one might want to include characters like \n and \t.

For example, I was building the "map position" helper at the bottom right of https://ansi.tools, and wanted the position to advance by 1 for newline characters.

Should probably be customizable indeed to set "greediness".

Perhaps a tab \t can serve as another example: if one wants to mark the truncated part with some background color, the tab should be included/marked as well (it's not zero-width). If you agree I can see if we should add this behavior for tabs as well in this PR.

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