本文整理匯總了TypeScript中omnisharp-client.CompositeDisposable.add方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CompositeDisposable.add方法的具體用法?TypeScript CompositeDisposable.add怎麽用?TypeScript CompositeDisposable.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類omnisharp-client.CompositeDisposable
的用法示例。
在下文中一共展示了CompositeDisposable.add方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("formats code", () => {
const d = restoreBuffers();
const disposable = new CompositeDisposable();
disposable.add(d);
let tries = 5;
return atom.workspace.open("simple/code-format/UnformattedClass.cs")
.then((editor) => {
return execute(editor);
});
function execute(editor: Atom.TextEditor): any {
const promise = Omni.listener.formatRange
.take(1)
.toPromise()
.then(({request}) => {
expect(editor.getPath()).to.be.eql(request.FileName);
const expected = `public class UnformattedClass{ public const int TheAnswer = 42;}`;
const result = editor.getText().replace(/\r|\n/g, "");
try {
expect(result).to.contain(expected);
tries = 0;
} catch (e) {
if (tries > 0) {
return execute(editor);
} else {
tries = -1;
throw e;
}
} finally {
if (tries === -1) {
disposable.dispose();
throw new Error("Failed!");
} else if (tries === 0) {
disposable.dispose();
}
tries--;
}
});
codeFormat.format();
return promise;
}
});