Skip to content

Commit

Permalink
Merge branch 'master' into insert-mode
Browse files Browse the repository at this point in the history
Conflicts:
	test/scanner.test.ts
  • Loading branch information
jpoon committed Nov 20, 2015
2 parents 4a59063 + 396006b commit 37145b3
Show file tree
Hide file tree
Showing 15 changed files with 845 additions and 641 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Vim
[![Build Status](https://travis-ci.org/VSCodeVim/Vim.svg?branch=master)](https://travis-ci.org/VSCodeVim/Vim) [![Build status](https://ci.appveyor.com/api/projects/status/0t6ljij7g5h0ddx8?svg=true)](https://ci.appveyor.com/project/guillermooo/vim)

[![Build Status](https://travis-ci.org/VSCodeVim/Vim.svg?branch=master)](https://travis-ci.org/VSCodeVim/Vim)
# Vim

Vim for Visual Studio Code. *Coming Soon!* :gift:
Vim emulation for Visual Studio Code. *Coming Soon!* :gift:

## Contributing

... would be awesome! Take a look at [Extension API](https://code.visualstudio.com/docs/extensionAPI/overview) on how to get started.

## License

[MIT](LICENSE.txt)
93 changes: 72 additions & 21 deletions src/cmd_line/command_node.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,79 @@
import * as vscode from 'vscode';
import * as node from './node';
import * as util from '../util';
import fs = require('fs');

import vscode = require('vscode');

import node = require('./node');
import util = require('../util');

export interface WriteCommandArguments {
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 implements node.CommandBase {
name : string;
shortName : string;
args : Object;

constructor(args : Object = null) {
// TODO: implement other arguments.
this.name = 'write';
this.shortName = 'w';
this.args = args;
}

runOn(textEditor : vscode.TextEditor) : void {
if (this.args) {
util.showError("Not implemented.");
return;
}
textEditor.document.save();
}
name : string;
shortName : string;
args : WriteCommandArguments;

constructor(args : WriteCommandArguments = {}) {
this.name = 'write';
this.shortName = 'w';
this.args = args;
}

private doSave(textEditor : vscode.TextEditor) {
textEditor.document.save().then(
(ok) => {
if (ok) {
util.showInfo("File saved.");
} else {
util.showError("File not saved.");
}
},
(e) => util.showError(e)
);
};

runOn(textEditor : vscode.TextEditor) : void {
if (this.args.opt) {
util.showError("Not implemented.");
return;
} else if (this.args.file) {
util.showError("Not implemented.");
return;
} else if (this.args.append) {
util.showError("Not implemented.");
return;
} else if (this.args.cmd) {
util.showError("Not implemented.");
return;
}

fs.access(textEditor.document.fileName, fs.W_OK, (accessErr) => {
if (accessErr) {
if (this.args.bang) {
fs.chmod(textEditor.document.fileName, 666, (e) => {
if (e) {
util.showError(e.message);
} else {
this.doSave(textEditor);
}
});
} else {
util.showError(accessErr.message);
}
} else {
this.doSave(textEditor);
}
});
}
}
Loading

0 comments on commit 37145b3

Please sign in to comment.