Skip to content

Commit

Permalink
Merge pull request VSCodeVim#114 from VSCodeVim/tabs-to-spaces
Browse files Browse the repository at this point in the history
Cleanup: Tabs to Spaces
  • Loading branch information
jpoon committed Jan 2, 2016
2 parents 2c3ef85 + 0f5ce75 commit b79cad3
Show file tree
Hide file tree
Showing 36 changed files with 1,487 additions and 1,479 deletions.
9 changes: 8 additions & 1 deletion extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import ModeHandler from "./src/mode/modeHandler";
import {ModeName} from "./src/mode/mode";

var modeHandler : ModeHandler;
var extensionContext : vscode.ExtensionContext;

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "vim" is now active!');

extensionContext = context;

registerCommand(context, 'extension.showCmdLine', () => showCmdLine());

Expand Down Expand Up @@ -105,6 +108,10 @@ function registerCommand(context: vscode.ExtensionContext, command: string, call
}

function handleKeyEvent(key:string) {
modeHandler = modeHandler || new ModeHandler();
if (!modeHandler) {
modeHandler = new ModeHandler();
extensionContext.subscriptions.push(modeHandler);
}

modeHandler.handleKeyEvent(key);
}
12 changes: 7 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var gulp = require('gulp'),
tsd = require('gulp-tsd'),
shell = require('gulp-shell'),
mocha = require('gulp-mocha'),
soften = require('gulp-soften'),
trimlines = require('gulp-trimlines');

var paths = {
Expand All @@ -23,11 +24,12 @@ gulp.task('tsd', function (callback) {
});

gulp.task('trim-whitespace', function() {
return gulp.src([paths.scripts_ts, paths.tests_ts], { base: "./" })
.pipe(trimlines({
leading: false
}))
.pipe(gulp.dest('./'));
return gulp.src([paths.scripts_ts, paths.tests_ts], { base: "./" })
.pipe(soften(4))
.pipe(trimlines({
leading: false
}))
.pipe(gulp.dest('./'));
});

gulp.task('compile', ['trim-whitespace'], shell.task([
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"devDependencies": {
"gulp": "^3.9.0",
"gulp-mocha": "^2.2.0",
"gulp-soften": "0.0.1",
"gulp-shell": "^0.5.1",
"gulp-tsd": "^0.0.4",
"gulp-tslint": "^3.6.0",
Expand Down
56 changes: 28 additions & 28 deletions src/cmd_line/commands/quit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ import node = require('../node');
import error = require('../../error');

export interface QuitCommandArguments extends node.CommandArgs {
bang?: boolean;
range?: node.LineRange;
bang?: boolean;
range?: node.LineRange;
}

//
// Implements :quit
// http://vimdoc.sourceforge.net/htmldoc/editing.html#:quit
//
export class QuitCommand extends node.CommandBase {
protected _arguments : QuitCommandArguments;

constructor(args : QuitCommandArguments = {}) {
super();
this._name = 'quit';
this._shortName = 'q';
this._arguments = args;
}

get arguments() : QuitCommandArguments {
return this._arguments;
}

execute() : void {
this.quit();
}

private quit() {
// See https://github.com/Microsoft/vscode/issues/723
if ((this.activeTextEditor.document.isDirty || this.activeTextEditor.document.isUntitled)
&& !this.arguments.bang) {
throw error.VimError.fromCode(error.ErrorCode.E37);
}

vscode.commands.executeCommand('workbench.action.closeActiveEditor');
};
protected _arguments : QuitCommandArguments;

constructor(args : QuitCommandArguments = {}) {
super();
this._name = 'quit';
this._shortName = 'q';
this._arguments = args;
}

get arguments() : QuitCommandArguments {
return this._arguments;
}

execute() : void {
this.quit();
}

private quit() {
// See https://github.com/Microsoft/vscode/issues/723
if ((this.activeTextEditor.document.isDirty || this.activeTextEditor.document.isUntitled)
&& !this.arguments.bang) {
throw error.VimError.fromCode(error.ErrorCode.E37);
}

vscode.commands.executeCommand('workbench.action.closeActiveEditor');
};
}
128 changes: 64 additions & 64 deletions src/cmd_line/commands/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,81 @@ import util = require('../../util');
import error = require('../../error');

export interface WriteCommandArguments extends node.CommandArgs {
opt? : string;
optValue? : string;
bang? : boolean;
range? : node.LineRange;
file? : string;
append? : boolean;
cmd? : string;
opt? : string;
optValue? : string;
bang? : boolean;
range? : node.LineRange;
file? : string;
append? : boolean;
cmd? : string;
}

//
// Implements :write
// http://vimdoc.sourceforge.net/htmldoc/editing.html#:write
//
export class WriteCommand extends node.CommandBase {
protected _arguments : WriteCommandArguments;
protected _arguments : WriteCommandArguments;

constructor(args : WriteCommandArguments = {}) {
super();
this._name = 'write';
this._shortName = 'w';
this._arguments = args;
}
constructor(args : WriteCommandArguments = {}) {
super();
this._name = 'write';
this._shortName = 'w';
this._arguments = args;
}

get arguments() : WriteCommandArguments {
return this._arguments;
}
get arguments() : WriteCommandArguments {
return this._arguments;
}

execute() : void {
if (this.arguments.opt) {
util.showError("Not implemented.");
return;
} else if (this.arguments.file) {
util.showError("Not implemented.");
return;
} else if (this.arguments.append) {
util.showError("Not implemented.");
return;
} else if (this.arguments.cmd) {
util.showError("Not implemented.");
return;
}
execute() : void {
if (this.arguments.opt) {
util.showError("Not implemented.");
return;
} else if (this.arguments.file) {
util.showError("Not implemented.");
return;
} else if (this.arguments.append) {
util.showError("Not implemented.");
return;
} else if (this.arguments.cmd) {
util.showError("Not implemented.");
return;
}

if (this.activeTextEditor.document.isUntitled) {
throw error.VimError.fromCode(error.ErrorCode.E32);
}
if (this.activeTextEditor.document.isUntitled) {
throw error.VimError.fromCode(error.ErrorCode.E32);
}

fs.access(this.activeTextEditor.document.fileName, fs.W_OK, (accessErr) => {
if (accessErr) {
if (this.arguments.bang) {
fs.chmod(this.activeTextEditor.document.fileName, 666, (e) => {
if (e) {
util.showError(e.message);
} else {
this.save();
}
});
} else {
util.showError(accessErr.message);
}
} else {
this.save();
}
});
}
fs.access(this.activeTextEditor.document.fileName, fs.W_OK, (accessErr) => {
if (accessErr) {
if (this.arguments.bang) {
fs.chmod(this.activeTextEditor.document.fileName, 666, (e) => {
if (e) {
util.showError(e.message);
} else {
this.save();
}
});
} else {
util.showError(accessErr.message);
}
} else {
this.save();
}
});
}

private save() {
this.activeTextEditor.document.save().then(
(ok) => {
if (ok) {
util.showInfo("File saved.");
} else {
util.showError("File not saved.");
}
},
(e) => util.showError(e)
);
}
private save() {
this.activeTextEditor.document.save().then(
(ok) => {
if (ok) {
util.showInfo("File saved.");
} else {
util.showError("File not saved.");
}
},
(e) => util.showError(e)
);
}
}
Loading

0 comments on commit b79cad3

Please sign in to comment.