当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TextModel.applyEdits方法代码示例

本文整理汇总了TypeScript中vs/editor/common/model/textModel.TextModel.applyEdits方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextModel.applyEdits方法的具体用法?TypeScript TextModel.applyEdits怎么用?TypeScript TextModel.applyEdits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/editor/common/model/textModel.TextModel的用法示例。


在下文中一共展示了TextModel.applyEdits方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('model insert text with one newline eventing', () => {
		let e: ModelRawContentChangedEvent = null;
		thisModel.onDidChangeRawContent((_e) => {
			if (e !== null) {
				assert.fail();
			}
			e = _e;
		});
		thisModel.applyEdits([EditOperation.insert(new Position(1, 3), ' new line\nNo longer')]);
		assert.deepEqual(e, new ModelRawContentChangedEvent(
			[
				new ModelRawLineChanged(1, 'My new line First Line'),
				new ModelRawLineChanged(1, 'My new line'),
				new ModelRawLinesInserted(2, 2, ['No longer First Line']),
			],
			2,
			false,
			false
		));
	});
开发者ID:servicesgpr,项目名称:vscode,代码行数:20,代码来源:model.test.ts

示例2: testApplyEdits

	function testApplyEdits(initial: IBufferLineState[], edits: IEdit[], expected: IBufferLineState[]): void {
		const initialText = initial.map(el => el.text).join('\n');
		const model = new TextModel(initialText, TextModel.DEFAULT_CREATION_OPTIONS, new LanguageIdentifier('test', 0));
		for (let lineIndex = 0; lineIndex < initial.length; lineIndex++) {
			const lineTokens = initial[lineIndex].tokens;
			const lineTextLength = model.getLineMaxColumn(lineIndex + 1) - 1;
			model._tokens._setTokens(0, lineIndex, lineTextLength, TestToken.toTokens(lineTokens));
		}

		model.applyEdits(edits.map((ed) => ({
			identifier: null,
			range: ed.range,
			text: ed.text,
			forceMoveMarkers: false
		})));

		for (let lineIndex = 0; lineIndex < expected.length; lineIndex++) {
			const actualLine = model.getLineContent(lineIndex + 1);
			const actualTokens = model.getLineTokens(lineIndex + 1);
			assert.equal(actualLine, expected[lineIndex].text);
			assertLineTokens(actualTokens, expected[lineIndex].tokens);
		}
	}
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:23,代码来源:model.line.test.ts

示例3: test

	test('model delete text from many lines', () => {
		thisModel.applyEdits([EditOperation.delete(new Range(1, 4, 3, 5))]);
		assert.equal(thisModel.getLineCount(), 3);
		assert.equal(thisModel.getLineContent(1), 'My Third Line');
	});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:5,代码来源:model.test.ts

示例4: test

	test('decorations are updated when inserting text inside 3', () => {
		addDecoration(thisModel, 1, 1, 2, 16, 'myType');
		modelHasDecoration(thisModel, 1, 1, 2, 16, 'myType');
		thisModel.applyEdits([EditOperation.insert(new Position(2, 2), '\n')]);
		modelHasDecoration(thisModel, 1, 1, 3, 15, 'myType');
	});
开发者ID:AllureFer,项目名称:vscode,代码行数:6,代码来源:modelDecorations.test.ts


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