本文整理汇总了TypeScript中vs/editor/common/model/model.Model类的典型用法代码示例。如果您正苦于以下问题:TypeScript Model类的具体用法?TypeScript Model怎么用?TypeScript Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Independent model edit 1', () => {
moveTo(thisCursor, 2, 16, true);
thisModel.applyEdits([EditOperation.delete(new Range(2, 1, 2, 2))]);
cursorEqual(thisCursor, 2, 15, 1, 1);
});
示例2: test
test('decorations are updated when deleting one line text before it', () => {
addDecoration(thisModel, 1, 2, 3, 2, 'myType');
modelHasDecoration(thisModel, 1, 2, 3, 2, 'myType');
thisModel.applyEdits([EditOperation.delete(new Range(1, 1, 1, 2))]);
modelHasDecoration(thisModel, 1, 1, 3, 2, 'myType');
});
示例3: modelHasNoDecorations
function modelHasNoDecorations(model: Model) {
assert.equal(model.getAllDecorations().length, 0, 'Model has no decoration');
}
示例4: test
test('hasRanges', () => {
let lines = [
/* 1*/ '/**',
/* 2*/ ' * Comment',
/* 3*/ ' */',
/* 4*/ 'class A {',
/* 5*/ ' void foo() {',
/* 6*/ ' if (true) {',
/* 7*/ ' //hello',
/* 8*/ ' }',
/* 9*/ ' }',
/* 10*/ '}'];
let textModel = Model.createFromString(lines.join('\n'));
let foldingModel = new FoldingModel(textModel, new TestDecorationProvider(textModel));
let hiddenRangeModel = new HiddenRangeModel(foldingModel);
assert.equal(hiddenRangeModel.hasRanges(), false);
let ranges = computeRanges(textModel, false, null);
foldingModel.update(ranges);
foldingModel.toggleCollapseState([foldingModel.getRegionAtLine(1), foldingModel.getRegionAtLine(6)]);
assertRanges(hiddenRangeModel.hiddenRanges, [r(2, 3), r(7, 7)]);
assert.equal(hiddenRangeModel.hasRanges(), true);
assert.equal(hiddenRangeModel.isHidden(1), false);
assert.equal(hiddenRangeModel.isHidden(2), true);
assert.equal(hiddenRangeModel.isHidden(3), true);
assert.equal(hiddenRangeModel.isHidden(4), false);
assert.equal(hiddenRangeModel.isHidden(5), false);
assert.equal(hiddenRangeModel.isHidden(6), false);
assert.equal(hiddenRangeModel.isHidden(7), true);
assert.equal(hiddenRangeModel.isHidden(8), false);
assert.equal(hiddenRangeModel.isHidden(9), false);
assert.equal(hiddenRangeModel.isHidden(10), false);
foldingModel.toggleCollapseState([foldingModel.getRegionAtLine(4)]);
assertRanges(hiddenRangeModel.hiddenRanges, [r(2, 3), r(5, 9)]);
assert.equal(hiddenRangeModel.hasRanges(), true);
assert.equal(hiddenRangeModel.isHidden(1), false);
assert.equal(hiddenRangeModel.isHidden(2), true);
assert.equal(hiddenRangeModel.isHidden(3), true);
assert.equal(hiddenRangeModel.isHidden(4), false);
assert.equal(hiddenRangeModel.isHidden(5), true);
assert.equal(hiddenRangeModel.isHidden(6), true);
assert.equal(hiddenRangeModel.isHidden(7), true);
assert.equal(hiddenRangeModel.isHidden(8), true);
assert.equal(hiddenRangeModel.isHidden(9), true);
assert.equal(hiddenRangeModel.isHidden(10), false);
foldingModel.toggleCollapseState([foldingModel.getRegionAtLine(1), foldingModel.getRegionAtLine(6), foldingModel.getRegionAtLine(4)]);
assertRanges(hiddenRangeModel.hiddenRanges, []);
assert.equal(hiddenRangeModel.hasRanges(), false);
assert.equal(hiddenRangeModel.isHidden(1), false);
assert.equal(hiddenRangeModel.isHidden(2), false);
assert.equal(hiddenRangeModel.isHidden(3), false);
assert.equal(hiddenRangeModel.isHidden(4), false);
assert.equal(hiddenRangeModel.isHidden(5), false);
assert.equal(hiddenRangeModel.isHidden(6), false);
assert.equal(hiddenRangeModel.isHidden(7), false);
assert.equal(hiddenRangeModel.isHidden(8), false);
assert.equal(hiddenRangeModel.isHidden(9), false);
assert.equal(hiddenRangeModel.isHidden(10), false);
});
示例5: test
test('Microsoft/monaco-editor#122: Unhandled Exception: TypeError: Unable to get property \'replace\' of undefined or null reference', () => {
function assertViewLineTokens(model: Model, lineNumber: number, forceTokenization: boolean, expected: ViewLineToken[]): void {
if (forceTokenization) {
model.forceTokenization(lineNumber);
}
let actual = model.getLineTokens(lineNumber).inflate();
let decode = (token: ViewLineToken) => {
return {
endIndex: token.endIndex,
foreground: token.getForeground()
};
};
assert.deepEqual(actual.map(decode), expected.map(decode));
}
let _tokenId = 10;
const LANG_ID1 = 'indicisiveMode1';
const LANG_ID2 = 'indicisiveMode2';
const languageIdentifier1 = new LanguageIdentifier(LANG_ID1, 3);
const languageIdentifier2 = new LanguageIdentifier(LANG_ID2, 4);
const tokenizationSupport: ITokenizationSupport = {
getInitialState: () => NULL_STATE,
tokenize: undefined,
tokenize2: (line, state) => {
let myId = ++_tokenId;
let tokens = new Uint32Array(2);
tokens[0] = 0;
tokens[1] = (
myId << MetadataConsts.FOREGROUND_OFFSET
) >>> 0;
return new TokenizationResult2(tokens, state);
}
};
let registration1 = TokenizationRegistry.register(LANG_ID1, tokenizationSupport);
let registration2 = TokenizationRegistry.register(LANG_ID2, tokenizationSupport);
let model = Model.createFromString('A model with\ntwo lines');
assertViewLineTokens(model, 1, true, [createViewLineToken(12, 1)]);
assertViewLineTokens(model, 2, true, [createViewLineToken(9, 1)]);
model.setMode(languageIdentifier1);
assertViewLineTokens(model, 1, true, [createViewLineToken(12, 11)]);
assertViewLineTokens(model, 2, true, [createViewLineToken(9, 12)]);
model.setMode(languageIdentifier2);
assertViewLineTokens(model, 1, false, [createViewLineToken(12, 1)]);
assertViewLineTokens(model, 2, false, [createViewLineToken(9, 1)]);
model.dispose();
registration1.dispose();
registration2.dispose();
function createViewLineToken(endIndex: number, foreground: number): ViewLineToken {
let metadata = (
(foreground << MetadataConsts.FOREGROUND_OFFSET)
) >>> 0;
return new ViewLineToken(endIndex, metadata);
}
});
示例6:
teardown(() => {
model.dispose();
model = null;
languageRegistration.dispose();
languageRegistration = null;
});
示例7:
teardown(function () {
model.dispose();
});