當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Model.getLineCount方法代碼示例

本文整理匯總了TypeScript中vs/editor/common/model/model.Model.getLineCount方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Model.getLineCount方法的具體用法?TypeScript Model.getLineCount怎麽用?TypeScript Model.getLineCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/editor/common/model/model.Model的用法示例。


在下文中一共展示了Model.getLineCount方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('model insert text with two newlines', () => {
		thisModel.applyEdits([EditOperation.insert(new Position(1, 3), ' new line\nOne more line in the middle\nNo longer')]);
		assert.equal(thisModel.getLineCount(), 7);
		assert.equal(thisModel.getLineContent(1), 'My new line');
		assert.equal(thisModel.getLineContent(2), 'One more line in the middle');
		assert.equal(thisModel.getLineContent(3), 'No longer First Line');
	});
開發者ID:Chan-PH,項目名稱:vscode,代碼行數:7,代碼來源:model.test.ts

示例2: test

	test('bug #16740: [editor] Cut line doesn\'t quite cut the last line', () => {
		// Part 1 => there is text on the last line
		let text = [
			'asdasd',
			'qwerty'
		];
		let model = new Model(text.join('\n'), null);
		let cursor = new Cursor(1, new MockConfiguration({ insertSpaces: false, tabSize: 4 }), model, null, true);

		moveTo(cursor, 2, 1, false);
		cursorEqual(cursor, 2, 1, 2, 1);

		cursorCommand(cursor, H.Cut, null, null, 'keyboard');
		assert.equal(model.getLineCount(), 1);
		assert.equal(model.getLineContent(1), 'asdasd');

		cursor.dispose();
		model.dispose();

		// Part 2 => there is no text on the last line
		text = [
			'asdasd',
			''
		];
		model = new Model(text.join('\n'), null);
		cursor = new Cursor(1, new MockConfiguration({ insertSpaces: false, tabSize: 4 }), model, null, true);

		moveTo(cursor, 2, 1, false);
		cursorEqual(cursor, 2, 1, 2, 1);

		cursorCommand(cursor, H.Cut, null, null, 'keyboard');
		assert.equal(model.getLineCount(), 1);
		assert.equal(model.getLineContent(1), 'asdasd');

		cursorCommand(cursor, H.Cut, null, null, 'keyboard');
		assert.equal(model.getLineCount(), 1);
		assert.equal(model.getLineContent(1), '');

		cursor.dispose();
		model.dispose();
	});
開發者ID:amamut,項目名稱:vscode,代碼行數:41,代碼來源:cursor.test.ts

示例3: assertSingleEditOp

	function assertSingleEditOp(singleEditOp:IIdentifiedSingleEditOperation, editedLines:string[]) {
		var editOp = [singleEditOp];

		var inverseEditOp = model.applyEdits(editOp);

		assert.equal(model.getLineCount(), editedLines.length);
		for (var i = 0; i < editedLines.length; i++) {
			assert.equal(model.getLineContent(i + 1), editedLines[i]);
		}

		var originalOp = model.applyEdits(inverseEditOp);

		assert.equal(model.getLineCount(), 5);
		assert.equal(model.getLineContent(1), LINE1);
		assert.equal(model.getLineContent(2), LINE2);
		assert.equal(model.getLineContent(3), LINE3);
		assert.equal(model.getLineContent(4), LINE4);
		assert.equal(model.getLineContent(5), LINE5);

		assert.deepEqual(originalOp, editOp);
	}
開發者ID:BMGburger,項目名稱:vscode,代碼行數:21,代碼來源:modelEditOperation.test.ts


注:本文中的vs/editor/common/model/model.Model.getLineCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。