mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable } from 'vscode';
|
||||
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable, EndOfLine } from 'vscode';
|
||||
import { createRandomFile, deleteFile, cleanUp, pathEquals } from './utils';
|
||||
import { join, basename } from 'path';
|
||||
import * as fs from 'fs';
|
||||
@@ -160,6 +160,86 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('eol, read', () => {
|
||||
const a = createRandomFile('foo\nbar\nbar').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
assert.equal(doc.eol, EndOfLine.LF);
|
||||
});
|
||||
});
|
||||
const b = createRandomFile('foo\nbar\nbar\r\nbaz').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
assert.equal(doc.eol, EndOfLine.LF);
|
||||
});
|
||||
});
|
||||
const c = createRandomFile('foo\r\nbar\r\nbar').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
assert.equal(doc.eol, EndOfLine.CRLF);
|
||||
});
|
||||
});
|
||||
return Promise.all([a, b, c]);
|
||||
});
|
||||
|
||||
// test('eol, change via editor', () => {
|
||||
// return createRandomFile('foo\nbar\nbar').then(file => {
|
||||
// return workspace.openTextDocument(file).then(doc => {
|
||||
// assert.equal(doc.eol, EndOfLine.LF);
|
||||
// return window.showTextDocument(doc).then(editor => {
|
||||
// return editor.edit(builder => builder.setEndOfLine(EndOfLine.CRLF));
|
||||
|
||||
// }).then(value => {
|
||||
// assert.ok(value);
|
||||
// assert.ok(doc.isDirty);
|
||||
// assert.equal(doc.eol, EndOfLine.CRLF);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// test('eol, change via applyEdit', () => {
|
||||
// return createRandomFile('foo\nbar\nbar').then(file => {
|
||||
// return workspace.openTextDocument(file).then(doc => {
|
||||
// assert.equal(doc.eol, EndOfLine.LF);
|
||||
|
||||
// const edit = new WorkspaceEdit();
|
||||
// edit.set(file, [TextEdit.setEndOfLine(EndOfLine.CRLF)]);
|
||||
// return workspace.applyEdit(edit).then(value => {
|
||||
// assert.ok(value);
|
||||
// assert.ok(doc.isDirty);
|
||||
// assert.equal(doc.eol, EndOfLine.CRLF);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// test('eol, change via onWillSave', () => {
|
||||
|
||||
// let called = false;
|
||||
// let sub = workspace.onWillSaveTextDocument(e => {
|
||||
// called = true;
|
||||
// e.waitUntil(Promise.resolve([TextEdit.setEndOfLine(EndOfLine.LF)]));
|
||||
// });
|
||||
|
||||
// return createRandomFile('foo\r\nbar\r\nbar').then(file => {
|
||||
// return workspace.openTextDocument(file).then(doc => {
|
||||
// assert.equal(doc.eol, EndOfLine.CRLF);
|
||||
// const edit = new WorkspaceEdit();
|
||||
// edit.set(file, [TextEdit.insert(new Position(0, 0), '-changes-')]);
|
||||
|
||||
// return workspace.applyEdit(edit).then(success => {
|
||||
// assert.ok(success);
|
||||
// return doc.save();
|
||||
|
||||
// }).then(success => {
|
||||
// assert.ok(success);
|
||||
// assert.ok(called);
|
||||
// assert.ok(!doc.isDirty);
|
||||
// assert.equal(doc.eol, EndOfLine.LF);
|
||||
// sub.dispose();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
|
||||
return createRandomFile().then(file => {
|
||||
let disposables: Disposable[] = [];
|
||||
|
||||
Reference in New Issue
Block a user