Skip to content

Commit

Permalink
Merge branch 'master' of github.com:VSCodeVim/Vim
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoon committed Dec 30, 2015
2 parents 5a081b1 + e1f7879 commit 2c3ef85
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
out
node_modules
typings
typings
.vscode-test
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ env:
- TSD_GITHUB_TOKEN=8742b29e67faa29aa25564ff7317b50fd7c1327d

install:
- npm install
before_script:
- npm install -g gulp
- gulp init
script:
- gulp
- npm install

script:
- gulp
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,21 @@
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
"test": "node ./node_modules/vscode/bin/test",
"postinstall": "gulp init"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-mocha": "^2.2.0",
"gulp-shell": "^0.5.1",
"gulp-tsd": "0.0.4",
"gulp-tsd": "^0.0.4",
"gulp-tslint": "^3.6.0",
"gulp-trimlines": "^1.0.0",
"gulp-typescript": "^2.9.2",
"tsd": "^0.6.5",
"tslint": "^3.2.1",
"typescript": "^1.6.2",
"vscode": "0.10.x"
"vscode": "^0.10.7"
},
"dependencies": {
"lodash": "^3.10.1"
Expand Down
14 changes: 8 additions & 6 deletions src/motion/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export enum MotionMode {
export class Motion implements vscode.Disposable {
/// Certain motions like j, k, and | record data about the desired column within the span.
/// This value may or may not be a valid point within the line
private _desiredColumn: number = 0;
private _desiredColumn: number = 0;
private _motionMode : MotionMode;
private _position : Position;
private _selectionChangeHandler : vscode.Disposable;
private _position : Position;
private _disposables: vscode.Disposable[];

public get position() : Position {
return this._position;
Expand All @@ -26,7 +26,7 @@ export class Motion implements vscode.Disposable {
this.changeMode(mode);
}

this._selectionChangeHandler = vscode.window.onDidChangeTextEditorSelection(e => {
this._disposables.push(vscode.window.onDidChangeTextEditorSelection(e => {
let selection = e.selections[0];

if (selection) {
Expand All @@ -36,7 +36,7 @@ export class Motion implements vscode.Disposable {
this.setPosition(new Position(line, char), true);
this.changeMode(this._motionMode);
}
});
}));
}

public changeMode(mode : MotionMode) : Motion {
Expand Down Expand Up @@ -143,7 +143,9 @@ export class Motion implements vscode.Disposable {
}

dispose() {
this._selectionChangeHandler.dispose();
_.each(this._disposables, d => {
d.dispose();
});
}

private setPosition(position: Position, updateDesiredColumn = false) {
Expand Down
7 changes: 3 additions & 4 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as vscode from 'vscode';
import * as _ from 'lodash';

suite("setup", () => {
test("all keys have handlers", (done) => {
test("all keys have handlers", () => {
let pkg = require(__dirname + '/../../package.json');
assert.ok(pkg);

vscode.commands.getCommands()
return vscode.commands.getCommands()
.then(registeredCommands => {
let keybindings = pkg.contributes.keybindings;
assert.ok(pkg);
Expand All @@ -18,8 +18,7 @@ suite("setup", () => {
var found = registeredCommands.indexOf(keybinding.command) >= -1;
assert.ok(found, "Missing handler for key=" + keybinding.key + ". Expected handler=" + keybinding.command);
}
})
.then(done, done);
});
});

test("duplicate keybindings", () => {
Expand Down
24 changes: 12 additions & 12 deletions test/textEditor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,51 @@ suite("text editor", () => {
TextEditor.delete().then(() => done());
});

test("insert 'Hello World'", done => {
test("insert 'Hello World'", () => {
let expectedText = "Hello World";

TextEditor.insert(expectedText).then(x => {
return TextEditor.insert(expectedText).then(x => {
assert.equal(vscode.window.activeTextEditor.document.lineCount, 1);
let actualText = TextEditor.readLine(0);
assert.equal(actualText, expectedText);
}).then(done, done);
});
});

test("replace 'World' with 'Foo Bar'", done => {
test("replace 'World' with 'Foo Bar'", () => {
let newText = "Foo Bar";
let start = new vscode.Position(0, 6);
let end = new vscode.Position(0, 11);
let range : vscode.Range = new vscode.Range(start, end);

TextEditor.replace(range, newText).then( x => {
return TextEditor.replace(range, newText).then( x => {
assert.equal(vscode.window.activeTextEditor.document.lineCount, 1);

let actualText = TextEditor.readLine(0);
assert.equal(actualText, "Hello Foo Bar");
}).then(done, done);
});
});

test("delete `Hello`", done => {
test("delete `Hello`", () => {
assert.equal(vscode.window.activeTextEditor.document.lineCount, 1);

var end = new vscode.Position(0, 5);
var range = new vscode.Range(new vscode.Position(0, 0), end);

TextEditor.delete(range).then( x => {
return TextEditor.delete(range).then( x => {
let actualText = TextEditor.readLine(0);
assert.equal(actualText, " Foo Bar");
}).then(done, done);
});
});

test("delete the whole line", done => {
test("delete the whole line", () => {
assert.equal(vscode.window.activeTextEditor.document.lineCount, 1);

var range = vscode.window.activeTextEditor.document.lineAt(0).range;

TextEditor.delete(range).then( x => {
return TextEditor.delete(range).then(x => {
let actualText = TextEditor.readLine(0);
assert.equal(actualText, "");
}).then(done, done);
});
});

test("try to read lines that don't exist", () => {
Expand Down

0 comments on commit 2c3ef85

Please sign in to comment.