Skip to content

Commit

Permalink
Delete the printFn option more safely
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Sep 22, 2024
1 parent 82e03f4 commit 9404193
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/nrepl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { BEncoderStream, BDecoderStream } from './bencode';
import * as cider from './cider';
import * as state from './../state';
import * as util from '../utilities';
import { PrettyPrintingOptions, disabledPrettyPrinter, getServerSidePrinter } from '../printer';
import {
PrettyPrintingOptions,
disabledPrettyPrinter,
getServerSidePrinter,
prettyPrint,
} from '../printer';
import * as debug from '../debugger/calva-debug';
import * as vscode from 'vscode';
import debugDecorations from '../debugger/decorations';
import * as outputWindow from '../repl-window/repl-doc';
import { formatAsLineComments } from '../results-output/util';
import type { ReplSessionType } from '../config';
import { getStateValue, prettyPrint } from '../../out/cljs-lib/cljs-lib';
import { getStateValue } from '../../out/cljs-lib/cljs-lib';
import { getConfig } from '../config';
import { log, Direction } from './logging';
import * as string from '../util/string';
Expand Down
4 changes: 3 additions & 1 deletion src/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@ export function getServerSidePrinterDependencies() {
}

export function prettyPrint(value: any, options: any = prettyPrintingOptions()) {
return calvaLib.prettyPrint(value, options);
const optionsClone = JSON.parse(JSON.stringify(options));
delete optionsClone['printFn']; // Zprint croaks on options it doesn't understand
return calvaLib.prettyPrint(value, optionsClone);
}
1 change: 0 additions & 1 deletion src/results-output/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ function appendClojure(
}
} else if (destination === 'terminal') {
const printerOptions = { ...printer.prettyPrintingOptions(), 'color?': true };
delete printerOptions.printFn; // Zprint croaks on options it doesn't understand
const prettyMessage = printer.prettyPrint(message, printerOptions)?.value || message;
// TODO: Figure if it's worth a setting to opt-in on an ns info line
getOutputPTY().write(`${didLastTerminateLine ? '' : '\n'}${nsInfoLine(destination, options)}`);
Expand Down

0 comments on commit 9404193

Please sign in to comment.