• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript model.Model类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
	});
开发者ID:ansonn,项目名称:vscode,代码行数:6,代码来源:cursor.test.ts


示例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');
	});
开发者ID:SeanKilleen,项目名称:vscode,代码行数:6,代码来源:modelDecorations.test.ts


示例3: modelHasNoDecorations

function modelHasNoDecorations(model: Model) {
	assert.equal(model.getAllDecorations().length, 0, 'Model has no decoration');
}
开发者ID:SeanKilleen,项目名称:vscode,代码行数:3,代码来源:modelDecorations.test.ts


示例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);

	});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:67,代码来源:hiddenRangeModel.test.ts


示例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);
		}
	});
开发者ID:hungys,项目名称:vscode,代码行数:64,代码来源:textModelWithTokens.test.ts


示例6:

	teardown(() => {
		model.dispose();
		model = null;
		languageRegistration.dispose();
		languageRegistration = null;
	});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:6,代码来源:splitLinesCollection.test.ts


示例7:

	teardown(function () {
		model.dispose();
	});
开发者ID:armanio123,项目名称:vscode,代码行数:3,代码来源:snippetController2.test.ts



注:本文中的vs/editor/common/model/model.Model类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript modelLine.computeIndentLevel函数代码示例发布时间:2022-05-25
下一篇:
TypeScript mirrorTextModel.MirrorTextModel类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap