"use strict";

import * as vs from "vscode";
import * as path from "path";
import { config } from "./config";

export class DartIndentFixer {
	onDidChangeActiveTextEditor(editor: vs.TextEditor) {
		if (!(editor && editor.document))
			return;

		let isDart = editor.document.languageId === "dart";
		let isPubspec = editor.document.languageId === "yaml" && path.basename(editor.document.fileName).toLowerCase() == "pubspec.yaml";
		if (config.setIndentation && (isDart || isPubspec)) {
			editor.options = {
				insertSpaces: true,
				tabSize: 2
			};
		}
	}
}

"use strict";

import * as vs from "vscode";
import { config } from "./config";

export class DartIndentFixer {
	onDidChangeActiveTextEditor(editor: vs.TextEditor) {
		if (editor && editor.document.languageId === "dart" && config.setIndentation) {
			editor.options = {
				insertSpaces: true,
				tabSize: 2
			};
		}
	}
}

--- 
+++ 
@@ -1,11 +1,17 @@
 "use strict";
 
 import * as vs from "vscode";
+import * as path from "path";
 import { config } from "./config";
 
 export class DartIndentFixer {
 	onDidChangeActiveTextEditor(editor: vs.TextEditor) {
-		if (editor && editor.document.languageId === "dart" && config.setIndentation) {
+		if (!(editor && editor.document))
+			return;
+
+		let isDart = editor.document.languageId === "dart";
+		let isPubspec = editor.document.languageId === "yaml" && path.basename(editor.document.fileName).toLowerCase() == "pubspec.yaml";
+		if (config.setIndentation && (isDart || isPubspec)) {
 			editor.options = {
 				insertSpaces: true,
 				tabSize: 2
Apply 2-space indents to pubspec.yaml too.

Fixes #140.
