microsoft / microsoft/vscode

New file created via Ctrl+N / File > New File requires saving before language mode can be set (regression?)

Open
#329,742 0 comments 0 reactions 1 assignee Claimed by @hediet View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

```markdown
### Does this issue occur when all extensions are disabled?

Yes

### Steps to Reproduce

1. Open VS Code (no folder/workspace needs to be open).
2. Create a new untitled file:
- Either press `Ctrl+N` (Windows/Linux) / `Cmd+N` (macOS), or
- Use the menu: `File > New File...` and pick a plain "Text File".
3. Without saving, try to assign a specific language mode to the untitled file
(e.g. via the status bar language indicator, or `Ctrl+K M`).
4. Observe whether the language mode picker is available/effective before the
file is saved to disk.

### Expected

The language mode (format) of a new, unsaved file can be set immediately after
creation, without requiring the file to be saved first — this was the previous
behavior.

### Actual

The file must be saved before a language mode can be properly
assigned/persisted. Setting the language mode on an unsaved file either
doesn't stick, isn't available, or requires an extra manual step that wasn't
needed before.

### Additional context

Originally reported in #250633, which was closed as `not planned` due to
missing reproduction details (`info-needed`) and has since been locked.
Re-opening with a clearer reproduction since the original reporter could no
longer respond in the locked thread.

A duplicate exists in microsoft/vscode-wiki#345 (opened in the wrong repo).

### VS Code Version

1.132.0 (commit df53daabb18cd157bdb08c7f01c34df936cf12f4, arm64)

### OS Version

macOS 26.5.2
```

## PR (once a fix is confirmed and implemented)

**Suggested branch name (in the microsoft/vscode fork):**
```
fix/new-file-language-mode
```

**Title:**
```
Fix language mode selection on unsaved new files
```

**Description body (include the closing keyword):**
```markdown
Fixes #250633

## What changed

## How to test

1. Ctrl+N / Cmd+N to open a new untitled file.
2. Set the language mode without saving (Ctrl+K M or status bar picker).
3. Confirm the mode is applied and persists.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.