diff --git a/CHANGELOG.md b/CHANGELOG.md index fd855a6c8..16decfc82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changes to Calva. ## [Unreleased] - [Synchronize the file extensions for Calva and Calva Spritz](https://github.com/BetterThanTomorrow/calva/issues/2629) +- [Terminal output pretty printing fails when using `printerFn` pretty print option](https://github.com/BetterThanTomorrow/calva/issues/2630) ## [2.0.473] - 2024-09-21 diff --git a/src/nrepl/index.ts b/src/nrepl/index.ts index 43c49c0e2..b665d5382 100644 --- a/src/nrepl/index.ts +++ b/src/nrepl/index.ts @@ -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'; diff --git a/src/printer.ts b/src/printer.ts index eb1b9f7e0..7464e4b3c 100644 --- a/src/printer.ts +++ b/src/printer.ts @@ -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); }