diff options
author | Alex Dima <alexdima@microsoft.com> | 2016-05-13 16:09:42 +0300 |
---|---|---|
committer | Alex Dima <alexdima@microsoft.com> | 2016-05-13 16:12:29 +0300 |
commit | def9e32467ad6e4f48787d38caf190acbfee5880 (patch) | |
tree | 0eeb6aca8c69f46db22d6c5cc7482cadbeb8e2c5 | |
parent | 5cfbd6b32fb4e6a2684a6fda96722115ca12c4af (diff) |
Fixes #6281: Do not truncate line number, column in position1.1.1
-rw-r--r-- | extensions/vscode-api-tests/src/editor.test.ts | 25 | ||||
-rw-r--r-- | src/vs/editor/common/core/position.ts | 4 |
2 files changed, 26 insertions, 3 deletions
diff --git a/extensions/vscode-api-tests/src/editor.test.ts b/extensions/vscode-api-tests/src/editor.test.ts index e3bb24f42c2..13388234f78 100644 --- a/extensions/vscode-api-tests/src/editor.test.ts +++ b/extensions/vscode-api-tests/src/editor.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import * as fs from 'fs'; import * as os from 'os'; -import {workspace, window, Position} from 'vscode'; +import {workspace, window, Position, Range} from 'vscode'; import {createRandomFile, deleteFile, cleanUp} from './utils'; import {join} from 'path'; @@ -38,4 +38,27 @@ suite("editor tests", () => { }); }); }); + + test('issue #6281: Edits fail to validate ranges correctly before applying', () => { + return createRandomFile('Hello world!').then(file => { + return workspace.openTextDocument(file).then(doc => { + return window.showTextDocument(doc).then((editor) => { + return editor.edit((builder) => { + builder.replace(new Range(0, 0, Number.MAX_VALUE, Number.MAX_VALUE), 'new'); + }).then(applied => { + assert.ok(applied); + assert.equal(doc.getText(), 'new'); + assert.ok(doc.isDirty); + + return doc.save().then(saved => { + assert.ok(saved); + assert.ok(!doc.isDirty); + + return deleteFile(file); + }); + }); + }); + }); + }); + }); });
\ No newline at end of file diff --git a/src/vs/editor/common/core/position.ts b/src/vs/editor/common/core/position.ts index 831442b1fcb..8094514361d 100644 --- a/src/vs/editor/common/core/position.ts +++ b/src/vs/editor/common/core/position.ts @@ -12,8 +12,8 @@ export class Position implements IEditorPosition { public column: number; constructor(lineNumber: number, column: number) { - this.lineNumber = lineNumber|0; - this.column = column|0; + this.lineNumber = lineNumber; + this.column = column; } public equals(other:IPosition): boolean { |