本文整理汇总了TypeScript中vs/editor/browser/editorBrowser.IActiveCodeEditor类的典型用法代码示例。如果您正苦于以下问题:TypeScript IActiveCodeEditor类的具体用法?TypeScript IActiveCodeEditor怎么用?TypeScript IActiveCodeEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IActiveCodeEditor类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: assertSelections
function assertSelections(editor: IActiveCodeEditor, ...s: Selection[]) {
for (const selection of editor.getSelections()) {
const actual = s.shift()!;
assert.ok(selection.equalsSelection(actual), `actual=${selection.toString()} <> expected=${actual.toString()}`);
}
assert.equal(s.length, 0);
}
示例2: Selection
test('snippets, newline NO whitespace adjust', () => {
editor.setSelection(new Selection(2, 5, 2, 5));
const session = new SnippetSession(editor, 'abc\n foo\n bar\n$0', 0, 0, false);
session.insert();
assert.equal(editor.getModel()!.getValue(), 'function foo() {\n abc\n foo\n bar\nconsole.log(a);\n}');
});
示例3: function
test('snippets, merge', function () {
editor.setSelection(new Selection(1, 1, 1, 1));
const session = new SnippetSession(editor, 'This ${1:is ${2:nested}}.$0');
session.insert();
session.next();
assertSelections(editor, new Selection(1, 9, 1, 15));
session.merge('really ${1:nested}$0');
assertSelections(editor, new Selection(1, 16, 1, 22));
session.next();
assertSelections(editor, new Selection(1, 22, 1, 22));
assert.equal(session.isAtLastPlaceholder, false);
session.next();
assert.equal(session.isAtLastPlaceholder, true);
assertSelections(editor, new Selection(1, 23, 1, 23));
session.prev();
editor.trigger('test', 'type', { text: 'AAA' });
// back to `really ${1:nested}`
session.prev();
assertSelections(editor, new Selection(1, 16, 1, 22));
// back to `${1:is ...}` which now grew
session.prev();
assertSelections(editor, new Selection(1, 6, 1, 25));
});
示例4: SnippetSession
test('Selecting text from left to right, and choosing item messes up code, #31199', function () {
const model = editor.getModel()!;
model.setValue('console.log');
let actual = SnippetSession.adjustSelection(model, new Selection(1, 12, 1, 9), 3, 0);
assert.ok(actual.equalsSelection(new Selection(1, 9, 1, 6)));
actual = SnippetSession.adjustSelection(model, new Selection(1, 9, 1, 12), 3, 0);
assert.ok(actual.equalsSelection(new Selection(1, 9, 1, 12)));
editor.setSelections([new Selection(1, 9, 1, 12)]);
new SnippetSession(editor, 'far', 3, 0).insert();
assert.equal(model.getValue(), 'console.far');
});