mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Fixes #6281: Do not truncate line number, column in position
This commit is contained in:
parent
de77d32034
commit
8cd47bb55e
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue