-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into insert-mode
Conflicts: test/scanner.test.ts
- Loading branch information
Showing
15 changed files
with
845 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.