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


TypeScript IModel.getValueInRange方法代码示例

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


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

示例1: resolve

	resolve(name: string): string {
		if (name === 'SELECTION' || name === 'TM_SELECTED_TEXT') {
			return this._model.getValueInRange(this._selection);

		} else if (name === 'TM_CURRENT_LINE') {
			return this._model.getLineContent(this._selection.positionLineNumber);

		} else if (name === 'TM_CURRENT_WORD') {
			const info = this._model.getWordAtPosition({
				lineNumber: this._selection.positionLineNumber,
				column: this._selection.positionColumn
			});
			return info ? info.word : '';

		} else if (name === 'TM_LINE_INDEX') {
			return String(this._selection.positionLineNumber - 1);

		} else if (name === 'TM_LINE_NUMBER') {
			return String(this._selection.positionLineNumber);

		} else if (name === 'TM_FILENAME') {
			return basename(this._model.uri.fsPath);

		} else if (name === 'TM_DIRECTORY') {
			const dir = dirname(this._model.uri.fsPath);
			return dir !== '.' ? dir : '';

		} else if (name === 'TM_FILEPATH') {
			return this._model.uri.fsPath;

		} else {
			return undefined;
		}
	}
开发者ID:hungys,项目名称:vscode,代码行数:34,代码来源:snippetVariables.ts

示例2: _cursorUnselectedMessage

	private static _cursorUnselectedMessage(model: IModel, range: Range): string {
		const valueLength = model.getValueLengthInRange(range);
		if (valueLength > 512) {
			return this.xCharsUnselected(valueLength);
		}
		return this.xUnselected(model.getValueInRange(range));
	}
开发者ID:FabianLauer,项目名称:vscode,代码行数:7,代码来源:accGenerator.ts

示例3: appendValueFromRange

function appendValueFromRange(base: string, model: IModel, range: Range): string {
	var result = base;
	if (result !== '') {
		result += model.getEOL();
	}
	return result + model.getValueInRange(range);
}
开发者ID:diarmaidm,项目名称:vscode,代码行数:7,代码来源:stageRanges.ts

示例4: _cursorMoveMessage

	private static _cursorMoveMessage(source: string, model: IModel, oldPosition: Position, newPosition: Position): string {

		if (source === 'moveWordCommand') {
			return model.getValueInRange(new Range(oldPosition.lineNumber, oldPosition.column, newPosition.lineNumber, newPosition.column));
		}

		const oldLineNumber = oldPosition.lineNumber;
		const oldColumn = oldPosition.column;
		const newLineNumber = newPosition.lineNumber;
		const newColumn = newPosition.column;

		// check going down via right arrow
		if (newLineNumber === oldLineNumber + 1 && newColumn === 1 && oldColumn === model.getLineMaxColumn(oldLineNumber)) {
			return this._cursorCharMessage(model, newPosition);
		}

		// check going up via up arrow
		if (newLineNumber === oldLineNumber - 1 && newColumn === model.getLineMaxColumn(newLineNumber) && oldColumn === 1) {
			return this._cursorCharMessage(model, newPosition);
		}

		const lineCount = model.getLineCount();
		if (oldLineNumber !== newLineNumber) {
			if (newLineNumber === lineCount) {
				// Last line does not have an EOL
				return model.getLineContent(newLineNumber);
			}
			return model.getLineContent(newLineNumber) + model.getEOL();
		}

		return this._cursorCharMessage(model, newPosition);
	}
开发者ID:FabianLauer,项目名称:vscode,代码行数:32,代码来源:accGenerator.ts

示例5: getDeleteOperation

	return changes.map((change, i) => {
		if (isInsertion(change)) {
			// Delete inserted range
			return getDeleteOperation(change);
		} else if (isDeletion(change)) {
			// Get the original lines and insert at the deleted position
			const value = original.getValueInRange(getLinesRangeWithOneSurroundingNewline(original, change.originalStartLineNumber, change.originalEndLineNumber));
			return EditOperation.insert(new Position(change.modifiedStartLineNumber + 1, 1), value);
		} else if (change.isCompletelySelected) {
			// If the entire change is selected, then revert the whole thing.
			const value = original.getValueInRange(new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber + 1, 1));
			return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber + 1, 1), value);
		} else {
			// If only a portion is selected, replace with the matching lines - e.g. if lines 2-4 are selected, replace with lines 2-4 from the original model (if they exist)
			const copyOffset = change.modifiedStartLineNumber - change.fullModifiedStartLineNumber;
			const numLinesToCopy = change.modifiedEndLineNumber - change.modifiedStartLineNumber;
			const copyStartLine = change.originalStartLineNumber + copyOffset;
			const copyEndLine = Math.min(copyStartLine + numLinesToCopy, original.getLineCount());
			if (copyStartLine > copyEndLine) {
				return getDeleteOperation(change);
			}

			// Compute the range to copy, and intersect with the full original range to validate
			const originalRange = new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber, original.getLineMaxColumn(change.originalEndLineNumber));
			const rangeToCopy = originalRange.intersectRanges(
				new Range(copyStartLine, 1, copyEndLine, original.getLineMaxColumn(copyEndLine)));

			// No intersection, so delete the added text
			if (!rangeToCopy) {
				return getDeleteOperation(change);
			}

			const value = original.getValueInRange(rangeToCopy);
			return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber, modified.getLineMaxColumn(change.modifiedEndLineNumber)), value);
		}
	});
开发者ID:diarmaidm,项目名称:vscode,代码行数:36,代码来源:stageRanges.ts


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