• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript strings.lastNonWhitespaceIndex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vs/base/common/strings.lastNonWhitespaceIndex函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lastNonWhitespaceIndex函数的具体用法?TypeScript lastNonWhitespaceIndex怎么用?TypeScript lastNonWhitespaceIndex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: getLineLastNonWhitespaceColumn

	public getLineLastNonWhitespaceColumn(lineNumber: number): number {
		const result = strings.lastNonWhitespaceIndex(this.getLineContent(lineNumber));
		if (result === -1) {
			return 0;
		}
		return result + 2;
	}
开发者ID:sameer-coder,项目名称:vscode,代码行数:7,代码来源:pieceTreeTextBuffer.ts


示例2: _getLastNonBlankColumn

	public static _getLastNonBlankColumn(txt: string, defaultValue: number): number {
		const r = strings.lastNonWhitespaceIndex(txt);
		if (r === -1) {
			return defaultValue;
		}
		return r + 2;
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:7,代码来源:diffComputer.ts


示例3: getLineLastNonWhitespaceColumn

		getLineLastNonWhitespaceColumn(lineNumber: number): number {
			let result = strings.lastNonWhitespaceIndex(this._line);
			if (result === -1) {
				return 0;
			}
			return result + 2;
		}
开发者ID:wei772,项目名称:vscode,代码行数:7,代码来源:cursorMoveHelper.test.ts


示例4: _deleteWordLeftWhitespace

	protected static _deleteWordLeftWhitespace(model: ICursorSimpleModel, position: Position): Range {
		const lineContent = model.getLineContent(position.lineNumber);
		const startIndex = position.column - 2;
		const lastNonWhitespace = strings.lastNonWhitespaceIndex(lineContent, startIndex);
		if (lastNonWhitespace + 1 < startIndex) {
			return new Range(position.lineNumber, lastNonWhitespace + 2, position.lineNumber, position.column);
		}
		return null;
	}
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:9,代码来源:cursorWordOperations.ts


示例5: containNonWhitespace

	public containNonWhitespace(text: string): boolean {
		// the text doesn't contain any non-whitespace character.
		let nonWhitespaceIdx = strings.lastNonWhitespaceIndex(text);

		if (nonWhitespaceIdx >= 0) {
			return true;
		}

		return false;
	}
开发者ID:SeanKilleen,项目名称:vscode,代码行数:10,代码来源:indentRules.ts


示例6: matchEnterRule

	private matchEnterRule(model: ITokenizedModel, indentConverter: IIndentConverter, tabSize: number, line: number, oneLineAbove: number, oneLineAboveText?: string) {
		let validPrecedingLine = oneLineAbove;
		while (validPrecedingLine >= 1) {
			// ship empty lines as empty lines just inherit indentation
			let lineContent;
			if (validPrecedingLine === oneLineAbove && oneLineAboveText !== undefined) {
				lineContent = oneLineAboveText;
			} else {
				lineContent = model.getLineContent(validPrecedingLine);
			}

			let nonWhitespaceIdx = strings.lastNonWhitespaceIndex(lineContent);
			if (nonWhitespaceIdx >= 0) {
				break;
			}
			validPrecedingLine--;
		}

		if (validPrecedingLine < 1 || line > model.getLineCount()) {
			return null;
		}

		let maxColumn = model.getLineMaxColumn(validPrecedingLine);
		let enter = LanguageConfigurationRegistry.getEnterAction(model, new Range(validPrecedingLine, maxColumn, validPrecedingLine, maxColumn));

		if (enter) {
			let enterPrefix = enter.indentation;
			let enterAction = enter.enterAction;

			if (enterAction.indentAction === IndentAction.None) {
				enterPrefix = enter.indentation + enterAction.appendText;
			} else if (enterAction.indentAction === IndentAction.Indent) {
				enterPrefix = enter.indentation + enterAction.appendText;
			} else if (enterAction.indentAction === IndentAction.IndentOutdent) {
				enterPrefix = enter.indentation;
			} else if (enterAction.indentAction === IndentAction.Outdent) {
				enterPrefix = indentConverter.unshiftIndent(enter.indentation) + enterAction.appendText;
			}
			let movingLineText = model.getLineContent(line);
			if (this.trimLeft(movingLineText).indexOf(this.trimLeft(enterPrefix)) >= 0) {
				let oldIndentation = strings.getLeadingWhitespace(model.getLineContent(line));
				let newIndentation = strings.getLeadingWhitespace(enterPrefix);
				let indentMetadataOfMovelingLine = LanguageConfigurationRegistry.getIndentMetadata(model, line);
				if (indentMetadataOfMovelingLine & IndentConsts.DECREASE_MASK) {
					newIndentation = indentConverter.unshiftIndent(newIndentation);
				}
				let newSpaceCnt = IndentUtil.getSpaceCnt(newIndentation, tabSize);
				let oldSpaceCnt = IndentUtil.getSpaceCnt(oldIndentation, tabSize);
				return newSpaceCnt - oldSpaceCnt;
			}
		}

		return null;
	}
开发者ID:SeanKilleen,项目名称:vscode,代码行数:54,代码来源:moveLinesCommand.ts


示例7: _goodIndentForLine

	private static _goodIndentForLine(config: CursorConfiguration, model: ITextModel, lineNumber: number): string {
		let action: IndentAction | EnterAction;
		let indentation: string;

		let expectedIndentAction = config.autoIndent ? LanguageConfigurationRegistry.getInheritIndentForLine(model, lineNumber, false) : null;
		if (expectedIndentAction) {
			action = expectedIndentAction.action;
			indentation = expectedIndentAction.indentation;
		} else if (lineNumber > 1) {
			let lastLineNumber = lineNumber - 1;
			for (lastLineNumber = lineNumber - 1; lastLineNumber >= 1; lastLineNumber--) {
				let lineText = model.getLineContent(lastLineNumber);
				let nonWhitespaceIdx = strings.lastNonWhitespaceIndex(lineText);
				if (nonWhitespaceIdx >= 0) {
					break;
				}
			}

			if (lastLineNumber < 1) {
				// No previous line with content found
				return null;
			}

			let maxColumn = model.getLineMaxColumn(lastLineNumber);
			let expectedEnterAction = LanguageConfigurationRegistry.getEnterAction(model, new Range(lastLineNumber, maxColumn, lastLineNumber, maxColumn));
			if (expectedEnterAction) {
				indentation = expectedEnterAction.indentation;
				action = expectedEnterAction.enterAction;
				if (action) {
					indentation += action.appendText;
				}
			}
		}

		if (action) {
			if (action === IndentAction.Indent) {
				indentation = TypeOperations.shiftIndent(config, indentation);
			}

			if (action === IndentAction.Outdent) {
				indentation = TypeOperations.unshiftIndent(config, indentation);
			}

			indentation = config.normalizeIndentation(indentation);
		}

		if (!indentation) {
			return null;
		}

		return indentation;
	}
开发者ID:jumpinjackie,项目名称:sqlopsstudio,代码行数:52,代码来源:cursorTypeOperations.ts


示例8: getLineLastNonWhitespaceColumn

	public getLineLastNonWhitespaceColumn(lineNumber: number): number {
		if (this._isDisposed) {
			throw new Error('TextModel.getLineLastNonWhitespaceColumn: Model is disposed');
		}
		if (lineNumber < 1 || lineNumber > this.getLineCount()) {
			throw new Error('Illegal value ' + lineNumber + ' for `lineNumber`');
		}

		var result = strings.lastNonWhitespaceIndex(this._lines[lineNumber - 1].text);
		if (result === -1) {
			return 0;
		}
		return result + 2;
	}
开发者ID:1424667164,项目名称:vscode,代码行数:14,代码来源:textModel.ts


示例9: _deleteWordLeftWhitespace

	private static _deleteWordLeftWhitespace(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState): EditOperationResult {
		let position = cursor.position;
		let lineContent = model.getLineContent(position.lineNumber);
		let startIndex = position.column - 2;
		let lastNonWhitespace = strings.lastNonWhitespaceIndex(lineContent, startIndex);
		if (lastNonWhitespace + 1 < startIndex) {
			let deleteRange = new Range(position.lineNumber, lastNonWhitespace + 2, position.lineNumber, position.column);
			return new EditOperationResult(new ReplaceCommand(deleteRange, ''), {
				shouldPushStackElementBefore: false,
				shouldPushStackElementAfter: false
			});
		}
		return null;
	}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:14,代码来源:cursorWordOperations.ts


示例10: _goodIndentForLine

	private static _goodIndentForLine(config: CursorConfiguration, model: ITokenizedModel, lineNumber: number): string {
		let lastLineNumber = lineNumber - 1;

		for (lastLineNumber = lineNumber - 1; lastLineNumber >= 1; lastLineNumber--) {
			let lineText = model.getLineContent(lastLineNumber);
			let nonWhitespaceIdx = strings.lastNonWhitespaceIndex(lineText);
			if (nonWhitespaceIdx >= 0) {
				break;
			}
		}

		if (lastLineNumber < 1) {
			// No previous line with content found
			return '\t';
		}

		let r = LanguageConfigurationRegistry.getEnterActionAtPosition(model, lastLineNumber, model.getLineMaxColumn(lastLineNumber));

		let indentation: string;
		if (r.enterAction.indentAction === IndentAction.Outdent) {
			let desiredIndentCount = ShiftCommand.unshiftIndentCount(r.indentation, r.indentation.length, config.tabSize);
			indentation = '';
			for (let i = 0; i < desiredIndentCount; i++) {
				indentation += '\t';
			}
			indentation = config.normalizeIndentation(indentation);
		} else {
			indentation = r.indentation;
		}

		let result = indentation + r.enterAction.appendText;
		if (result.length === 0) {
			// good position is at column 1, but we gotta do something...
			return '\t';
		}
		return result;
	}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:37,代码来源:cursorTypeOperations.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript strings.ltrim函数代码示例发布时间:2022-05-25
下一篇:
TypeScript strings.isUpperAsciiLetter函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap