如何在 vscode.window.showInformationMessage 中换行

Cor*_*eZz 10 visual-studio-code

我想用来vscode.window.showInformationMessage显示一些消息。但我不能在其中换行。

我想要的是:

title:xxx
description:xxx
Run Code Online (Sandbox Code Playgroud)

我实际得到:

title:xxx description:xxx
Run Code Online (Sandbox Code Playgroud)

我的代码:

vscode.window.showInformationMessage("title:xxx\ndescription:xxx");
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Sco*_*eak 11

正如OP在评论中已经指出的那样,对此功能的请求被提交为问题#48900,该问题已被关闭为“不会这样做”。VSCode 显式地从消息文本中去除换行符,并且 VSCode 团队希望保持这种方式。

2020 年 7 月 20 日,提交了一个新问题#101589,再次要求提供此功能,但经过一番讨论后,该问题最终也因“超出范围”而被拒绝。

我只是在答案中总结这些已经存在的信息,因此很明显问题已经得到解答。


Ale*_*lex 7

这不完全是解决方案,但您可以使用模式对话框选项。

vscode.window.showInformationMessage('First line\nSecond line\nThird line', { modal: true });
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

启用自定义对话框后,settings.json它看起来像:

vscode.window.showInformationMessage('First line\nSecond line\nThird line', { modal: true });
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述