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

[FIX] formatting: do not show escape character #3497

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/helpers/cells/cell_helpers.ts
Expand Up @@ -10,6 +10,9 @@ import { formatNumber, formatStandardNumber } from "../numbers";
export function formatValue(value: CellValue, format?: string): string {
switch (typeof value) {
case "string":
if (value.includes('\\"')) {
return value.replace(/\\"/g, '"');
}
return value;
case "boolean":
return value ? "TRUE" : "FALSE";
Expand Down
6 changes: 6 additions & 0 deletions tests/plugins/cell.test.ts
Expand Up @@ -62,6 +62,12 @@ describe("getCellText", () => {
});
expect(result).toBeCancelledBecause(CommandResult.TargetOutOfSheet);
});

test("escape character is not display when formatting string", () => {
const model = new Model();
setCellContent(model, "A1", '="hello \\"world\\""');
expect(getCell(model, "A1")?.formattedValue).toBe('hello "world"');
});
});

describe("link cell", () => {
Expand Down