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

Delete trailing new line character from pasted text #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nullnull
Copy link
Contributor

Problem

When copying single empty cell from Google Spreadsheet (or copy some values from Excel), pasting result includes extra empty row.

Cause

Because copied value from Google Spreadsheet's empty cell is "\n".

Solution

I think it's better to delete trailing new line character from pasted text.

src/matrix.ts Outdated
@@ -154,9 +154,10 @@ export function split<T>(
csv: string,
transform: (value: string) => T,
horizontalSeparator = "\t",
verticalSeparator: string | RegExp = /\r\n|\n|\r/
verticalSeparator = /\r\n|\n|\r/
Copy link
Owner

Choose a reason for hiding this comment

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

Please do not remove the ability to accept a string here

src/matrix.ts Outdated
): Matrix<T> {
return csv
.replace(new RegExp('(' + verticalSeparator.source + ')$'), '') // delete trailing new line character
Copy link
Owner

Choose a reason for hiding this comment

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

Please support getting a string here

@iddan
Copy link
Owner

iddan commented Jul 26, 2021

@nullnull can you please fix my comments so I can merge your PR?

@nullnull
Copy link
Contributor Author

@iddan Sorry for late reply. I've fixed it!

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