當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。