VS代码语言服务器管道输出向客户端的子管道输出

发布于 2025-01-17 12:27:46 字数 754 浏览 4 评论 0原文

我正在创建自己的语言服务器扩展。我已经将儿童程序的输出输送到控制台和扩展输出渠道。问题在于,运行儿童程序时的控制台输出更新,但仅在De ChildProcess关闭后才更新输出通道。您对如何解决此问题有建议吗?

这是我的代码的一部分:

let output = client.outputChannel
console.info("Start the sketch")
output.appendLine("Start the sketch")
let runProces = childProcess.spawn(command, 
{cwd: workDir, shell: true,  stdio: ['pipe', 'pipe', 'pipe']})

//Pipe childProcess output to extenstion output
runProces.stdout.on('data', data => {
    console.log(`${data}`)              
    output.append(data.toString())
    output.show();
})
            
runProces.stderr.on('data', (data) =>{
    console.log(`${data}`)
})

runProces.on('close', (close) =>{
    console.info(`Sketch ended`)
    output.appendLine("Sketch ended")
})

I'm creating my own language-server extension. I've piped the output of a childprocess to the console and the extension outputChannel. The problem is that the console output updates while running the childprocess but the outputChannel updates only after de childprocess is closed. Do you have suggestions on how to fix this?

Here's part of my code:

let output = client.outputChannel
console.info("Start the sketch")
output.appendLine("Start the sketch")
let runProces = childProcess.spawn(command, 
{cwd: workDir, shell: true,  stdio: ['pipe', 'pipe', 'pipe']})

//Pipe childProcess output to extenstion output
runProces.stdout.on('data', data => {
    console.log(`${data}`)              
    output.append(data.toString())
    output.show();
})
            
runProces.stderr.on('data', (data) =>{
    console.log(`${data}`)
})

runProces.on('close', (close) =>{
    console.info(`Sketch ended`)
    output.appendLine("Sketch ended")
})

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文