microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.64k stars 29.05k forks source link

Settings Need Multiline TextBox #79571

Closed kenlefeb closed 3 years ago

kenlefeb commented 5 years ago

Issue Type: Bug

This is very similar to #39969, but for the new Settings UI.

I use an extension (vscode-journal) that allows you to define a template (setting journal.tpl-entry) for creating new files, and these require the use of \n characters to specify new lines, however the Settings UI won't let me enter \n (it gets escaped), let alone an actual newline character.

VS Code version: Code 1.37.1 (f06011ac164ae4dc8e753a3fe7f9549844d15e35, 2019-08-15T16:17:55.855Z) OS version: Windows_NT x64 10.0.17763

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 x 2112)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.81GB (5.67GB free)| |Process Argv|.| |Screen Reader|no| |VM|0%|
Extensions (25) Extension|Author (truncated)|Version ---|---|--- whitespace-plus|dav|0.0.5 xml|Dot|2.5.0 EditorConfig|Edi|0.13.0 prettier-vscode|esb|1.9.0 markdown-table-formatter|fcr|1.4.3 gc-excelviewer|Gra|2.1.32 vscode-journal-view|Gru|0.0.25 vscode-guid|hea|1.4.15 vscode-peacock|joh|3.1.2 json-escaper|jos|1.1.0 chat|kar|0.21.0 vscode-language-babel|mgm|0.0.23 vscode-docker|ms-|0.7.0 remote-wsl|ms-|0.39.2 csharp|ms-|1.21.0 powershell|ms-|2019.5.0 vsliveshare|ms-|1.0.721 vsliveshare-audio|ms-|0.1.64 vsliveshare-pack|ms-|0.3.3 debugger-for-chrome|msj|4.11.7 debugger-for-edge|msj|1.0.11 vscode-journal|paj|0.9.1 vscode-redis|vit|1.2.0 markdown-pdf|yza|1.2.0 markdown-all-in-one|yzh|2.4.2 (1 theme extensions excluded)
justarandomgeek commented 4 years ago

I too need some multi-line settings for my Factorio Mod Debug extension, which has templates for two auto-generated commit messages in settings (in the version i'm about to upload...). Same problem with \n - it works fine if you set it directly in settings.json, but the GUI strips them and has no way to enter a newline.

rzhao271 commented 3 years ago

I downloaded the top 2.5k extensions and did a search to see how string settings with \n as part of the default value were being used. The settings are being used in one of three ways:

Snippets or actual executable code

"wxapp-helper.component.script": {
    "type": [
    "string",
    "null"
    ],
    "default": "Component({\n  data: {},\n  properties: {},\n  methods: {}\n})",
    "description": "%ext.config.component.script%"
}

Another example is jupyter.runStartupCommands, which could take in a block of Python commands.

In this case, we want to render a Monaco editor.

Hover labels and templates

"todo.file.defaultContent": {
    "type": "string",
    "description": "New todo files default content",
    "default": "\nTodo:\n  ☐ Item\n"
}

Other examples include gitlens.hovers.detailsMarkdownFormat and gitstash.explorer.labels.stashTooltipFormat.

In this case, we want to render a multiline textarea.

Line-break settings

"npm-intellisense.importLinebreak": {
    "type": "string",
    "default": ";\r\n",
    "description": "For import command. The linebreak used after the snippet"
}

In this case, we want to render the \r and \n explicitly, rather than display a textarea with a trailing newline.

roblourens commented 3 years ago

The others I saw which may be beyond the 2.5k top:

And several that are configuring line endings and are just \n

rzhao271 commented 3 years ago

Just a note that for the line break settings, I assume most of them can do the following instead:

An example setting that can be remodelled to this pattern is npm-intellisense.importLinebreak (from https://github.com/microsoft/vscode/issues/79571#issuecomment-864326119).

Edit: Or, the extension author can use a singleline text setting and parse the input like a regex. For example, the user could input \\r\\n to get \r\n newlines.

rzhao271 commented 3 years ago

\closedWith be81d88