Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/state/editors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ export class Editors implements vscode.Disposable {

// Now `hiddenEditors` only contains editors that are no longer visible, and
// `addedEditors` only contains editors that were not visible previously.
const defaultMode = this._extension.modes.defaultMode;

for (const addedEditor of addedEditors) {
const fallback = this._fallbacks.get(addedEditor.document);
Expand All @@ -622,6 +621,7 @@ export class Editors implements vscode.Disposable {
this._editors.set(addedEditor, fallback);
this._fallbacks.delete(addedEditor.document);
} else {
const defaultMode = this._getDefaultModeForEditor(addedEditor);
this._editors.set(
addedEditor, new PerEditorState(this._extension, addedEditor, defaultMode));
}
Expand Down Expand Up @@ -656,6 +656,25 @@ export class Editors implements vscode.Disposable {
}
}

/**
* Returns the default mode for a new editor, respecting language-specific
* overrides of `dance.defaultMode`.
*/
private _getDefaultModeForEditor(editor: vscode.TextEditor): Mode {
const config = vscode.workspace.getConfiguration(extensionName, editor.document);
const defaultModeName = config.get<string>("defaultMode");

if (defaultModeName !== undefined) {
const mode = this._extension.modes.get(defaultModeName);

if (mode !== undefined) {
return mode;
}
}

return this._extension.modes.defaultMode;
}

private _handleDidOpenTextDocument(document: vscode.TextDocument) {
// When changing the file type of a new file, the current document is closed
// and a new document with the same name and content is created. Attempt to
Expand Down