Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way for an extension to tell have vscode suggest .JSON when user saves file if it is not the main extension for json files #102438

Open
StephenWeatherford opened this issue Jul 13, 2020 · 1 comment
Labels
feature-request Request for new features or functionality languages-basic Basic language support issues
Milestone

Comments

@StephenWeatherford
Copy link

Issue Type: Bug

See microsoft/vscode-azurearmtools#809 (Save dialog for arm-template files should suggest saving with JSON extension like json files do)

  1. Install https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools
  2. Create a new file (don't save)
  3. Change the language to "ARM Resource Manager Template"
  4. CTRL+S
    !) the dialog doesn't give a suggestion for extension
    EXPECTED: vscode should suggest .JSON for the extension, but there appears to be no way to get that to happen.

MORE INFO:
Our package.json info looks like this for the arm-template language id:

        "languages": [
            {
                "id": "arm-template",
                "aliases": [
                    "Azure Resource Manager Template"
                ],
                "configuration": "dist/grammars/jsonc.arm.language-configuration.json"
            }
        ],

I can't put .json as our extension, because if I do, then all json files opened will use the arm-template language. Rather, we manually switch to arm-template when we detect a specific schema in a json file (https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#). This is the mechanism that we were told to use because vscode doesn't provide a way to detect language ID based on any content past the first line (see #69868 (comment)). Unfortunately, that means vscode doesn't know we're associated with json files.

VS Code version: Code - Insiders 1.48.0-insider (e7920dc, 2020-07-10T11:55:11.286Z)
OS version: Darwin x64 19.5.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2600)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
webgl: enabled
webgl2: enabled
Load (avg) 3, 3, 3
Memory (System) 16.00GB (0.80GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (5)
Extension Author (truncated) Version
gitlens eam 10.2.2
todo-tree Gru 0.0.178
vscode-dotnet-runtime ms- 0.1.2
vscode-typescript-tslint-plugin ms- 1.2.3
vscode-todo-highlight way 1.0.4
@alexdima
Copy link
Member

@aeschli @bpasero Perhaps we should introduce a new property in package.json for languages, called "defaultFileName" or "defaultFileExtension" or something like that and that could be picked up by the Save dialog.

Today the Save dialog relies on the "extensions" property, but that one was introduced for the mapping in the other direction, to determine a language id from a file name and not the other way around.

Related: #102032

@alexdima alexdima added feature-request Request for new features or functionality languages-basic Basic language support issues labels Jul 21, 2020
@alexdima alexdima added this to the Backlog milestone Jul 21, 2020
@alexdima alexdima removed their assignment Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality languages-basic Basic language support issues
Projects
None yet
Development

No branches or pull requests

2 participants