Skip to content

evalR(): each message() results in an extra newline #582

@HenrikBengtsson

Description

@HenrikBengtsson

Example

$ cat ./webR-message-newline.mjs

#! /usr/bin/env node
import { WebR } from "webr";
import WebSocket from "ws";

console.log('Node.js v', process.version);

// Launch webR instance
const webR = new WebR();
await webR.init();
console.log("webR v" + webR.version);

const code = `
cat("----------------------\n")
cat("abc")
cat("def")
cat("\n")
cat("ABC\n")
cat("DEF\n")
cat("----------------------\n")
message("abc", appendLF = FALSE)
message("def", appendLF = FALSE)
message("ABC\n", appendLF = FALSE)
message("DEF\n", appendLF = FALSE)
cat("----------------------\n")
message("abc", appendLF = TRUE)
message("def", appendLF = TRUE)
message("ABC\n", appendLF = TRUE)
message("DEF\n", appendLF = TRUE)
cat("----------------------\n")
`;

await webR.evalR(code);

process.exit(0);

gives

$ ./webR-message-newline.mjs
Node.js v v22.19.0
webR v0.5.6
----------------------
abcdef
ABC
DEF
----------------------
abc
def
ABC

DEF

----------------------
abc

def

ABC


DEF


----------------------

but I'd expect:

----------------------
abcdef
ABC
DEF
----------------------
abcdefABC
DEF
----------------------
abc
def
ABC

DEF

----------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions