-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
Copy formatted cell values to clipboard instead of raw values #3094
Conversation
- Improve readability - Add some more code working towards copy-paste so that the intent is clearer behind the separation of raw vs formatted values.
@ghislaineguerin you might also be interested in looking at this since it addresses an issue you originally reported. |
for (const rowId of this.getRowIds(cells)) { | ||
const plainTextRow: string[] = []; | ||
const tsvRow: string[] = []; | ||
const structuredRow: StructuredCell[] = []; | ||
for (const columnId of this.getColumnIds(cells)) { | ||
if (isCellSelected(cells, { rowIndex: rowId }, { id: columnId })) { | ||
const cellText = getCellText( | ||
indexedRecords, | ||
processedColumns, | ||
rowId, | ||
columnId, | ||
'raw', | ||
recordSummaries, | ||
); | ||
plainTextRow.push(cellText); | ||
const column = columns.get(columnId); | ||
if (!isCellSelected(cells, { rowIndex: rowId }, { id: columnId })) { | ||
// Ignore cells that are not selected. | ||
continue; | ||
} | ||
if (!column) { | ||
// Ignore cells with no associated column. This should never happen. | ||
continue; | ||
} | ||
const rawCellValue = getRawCellValue(indexedRecords, rowId, columnId); | ||
const formattedCellValue = getFormattedCellValue( | ||
rawCellValue, | ||
columns, | ||
columnId, | ||
recordSummaries, | ||
); | ||
const type = column.abstractType.identifier; | ||
structuredRow.push({ | ||
type, | ||
raw: rawCellValue, | ||
formatted: formattedCellValue, | ||
}); | ||
tsvRow.push(formattedCellValue); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seancolsen A minor nitpick.
For cases like these, where we don't have break out of the loop, I'd prefer iterating with forEach
and return
statements instead of a for loop and continue
.
I don't have a major concern towards removing the no-continue
rule, but I'm not a fan of continue
either.
No action item needed. I only wanted to share this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Fixes #3085
Notes
Checklist
Update index.md
).develop
branch of the repositoryDeveloper Certificate of Origin
Developer Certificate of Origin