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


TypeScript TextModel.getLineContent方法代碼示例

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


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

示例1: _doFindMatchesLineByLine

	private static _doFindMatchesLineByLine(model: TextModel, searchRange: Range, searchData: SearchData, captureMatches: boolean, limitResultCount: number): FindMatch[] {
		const result: FindMatch[] = [];
		let resultLen = 0;

		// Early case for a search range that starts & stops on the same line number
		if (searchRange.startLineNumber === searchRange.endLineNumber) {
			const text = model.getLineContent(searchRange.startLineNumber).substring(searchRange.startColumn - 1, searchRange.endColumn - 1);
			resultLen = this._findMatchesInLine(searchData, text, searchRange.startLineNumber, searchRange.startColumn - 1, resultLen, result, captureMatches, limitResultCount);
			return result;
		}

		// Collect results from first line
		const text = model.getLineContent(searchRange.startLineNumber).substring(searchRange.startColumn - 1);
		resultLen = this._findMatchesInLine(searchData, text, searchRange.startLineNumber, searchRange.startColumn - 1, resultLen, result, captureMatches, limitResultCount);

		// Collect results from middle lines
		for (let lineNumber = searchRange.startLineNumber + 1; lineNumber < searchRange.endLineNumber && resultLen < limitResultCount; lineNumber++) {
			resultLen = this._findMatchesInLine(searchData, model.getLineContent(lineNumber), lineNumber, 0, resultLen, result, captureMatches, limitResultCount);
		}

		// Collect results from last line
		if (resultLen < limitResultCount) {
			const text = model.getLineContent(searchRange.endLineNumber).substring(0, searchRange.endColumn - 1);
			resultLen = this._findMatchesInLine(searchData, text, searchRange.endLineNumber, 0, resultLen, result, captureMatches, limitResultCount);
		}

		return result;
	}
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:28,代碼來源:textModelSearch.ts

示例2: 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:JarnoNijboer,項目名稱:vscode,代碼行數:7,代碼來源:model.test.ts

示例3: assertSingleEditOp

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

		let inverseEditOp = model.applyEdits(editOp);

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

		let 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);

		const simplifyEdit = (edit: IIdentifiedSingleEditOperation) => {
			return {
				identifier: edit.identifier,
				range: edit.range,
				text: edit.text,
				forceMoveMarkers: edit.forceMoveMarkers,
				isAutoWhitespaceEdit: edit.isAutoWhitespaceEdit
			};
		};
		assert.deepEqual(originalOp.map(simplifyEdit), editOp.map(simplifyEdit));
	}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:30,代碼來源:modelEditOperation.test.ts

示例4: _doFindNextMatchLineByLine

	private static _doFindNextMatchLineByLine(model: TextModel, searchStart: Position, searchRegex: RegExp, captureMatches: boolean): FindMatch {
		const lineCount = model.getLineCount();
		const startLineNumber = searchStart.lineNumber;

		// Look in first line
		const text = model.getLineContent(startLineNumber);
		const r = this._findFirstMatchInLine(searchRegex, text, startLineNumber, searchStart.column, captureMatches);
		if (r) {
			return r;
		}

		for (let i = 1; i <= lineCount; i++) {
			const lineIndex = (startLineNumber + i - 1) % lineCount;
			const text = model.getLineContent(lineIndex + 1);
			const r = this._findFirstMatchInLine(searchRegex, text, lineIndex + 1, 1, captureMatches);
			if (r) {
				return r;
			}
		}

		return null;
	}
開發者ID:fs814,項目名稱:vscode,代碼行數:22,代碼來源:textModelSearch.ts

示例5: _doFindPreviousMatchLineByLine

	private static _doFindPreviousMatchLineByLine(model: TextModel, searchStart: Position, searcher: Searcher, captureMatches: boolean): FindMatch {
		const lineCount = model.getLineCount();
		const startLineNumber = searchStart.lineNumber;

		// Look in first line
		const text = model.getLineContent(startLineNumber).substring(0, searchStart.column - 1);
		const r = this._findLastMatchInLine(searcher, text, startLineNumber, captureMatches);
		if (r) {
			return r;
		}

		for (let i = 1; i <= lineCount; i++) {
			const lineIndex = (lineCount + startLineNumber - i - 1) % lineCount;
			const text = model.getLineContent(lineIndex + 1);
			const r = this._findLastMatchInLine(searcher, text, lineIndex + 1, captureMatches);
			if (r) {
				return r;
			}
		}

		return null;
	}
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:22,代碼來源:textModelSearch.ts

示例6: test

	test('snippets, typing at beginning', function () {

		editor.setSelection(new Selection(1, 2, 1, 2));
		const session = new SnippetSession(editor, 'farboo$0');
		session.insert();

		editor.setSelection(new Selection(1, 2, 1, 2));
		assert.equal(session.isSelectionWithinPlaceholders(), false);
		assert.equal(session.isAtLastPlaceholder, true);

		editor.trigger('test', 'type', { text: 'XXX' });
		assert.equal(model.getLineContent(1), 'fXXXfarboounction foo() {');
		assert.equal(session.isSelectionWithinPlaceholders(), false);

		session.next();
		assertSelections(editor, new Selection(1, 11, 1, 11));
	});
開發者ID:liunian,項目名稱:vscode,代碼行數:17,代碼來源:snippetSession.test.ts

示例7: 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

示例8: 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:JarnoNijboer,項目名稱:vscode,代碼行數:21,代碼來源:modelEditOperation.test.ts


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