本文整理汇总了TypeScript中vs/editor/common/model/textModel.TextModel.getLineCount方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextModel.getLineCount方法的具体用法?TypeScript TextModel.getLineCount怎么用?TypeScript TextModel.getLineCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/model/textModel.TextModel
的用法示例。
在下文中一共展示了TextModel.getLineCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _doFindPreviousMatchMultiline
private static _doFindPreviousMatchMultiline(model: TextModel, searchStart: Position, searcher: Searcher, captureMatches: boolean): FindMatch {
const matches = this._doFindMatchesMultiline(model, new Range(1, 1, searchStart.lineNumber, searchStart.column), searcher, captureMatches, 10 * LIMIT_FIND_COUNT);
if (matches.length > 0) {
return matches[matches.length - 1];
}
const lineCount = model.getLineCount();
if (searchStart.lineNumber !== lineCount || searchStart.column !== model.getLineMaxColumn(lineCount)) {
// Try again with all content
return this._doFindPreviousMatchMultiline(model, new Position(lineCount, model.getLineMaxColumn(lineCount)), searcher, captureMatches);
}
return null;
}
示例2: assertIndentGuides
function assertIndentGuides(lines: [number, string][]): void {
let text = lines.map(l => l[1]).join('\n');
let model = new TextModel([], TextModel.toRawText(text, TextModel.DEFAULT_CREATION_OPTIONS));
let actual: [number, string][] = [];
for (let line = 1; line <= model.getLineCount(); line++) {
actual[line - 1] = [model.getLineIndentGuide(line), model.getLineContent(line)];
}
// let expected = lines.map(l => l[0]);
assert.deepEqual(actual, lines);
model.dispose();
}
示例3: _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;
}
示例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;
}
示例5: _assertFindMatches
function _assertFindMatches(model: TextModel, searchParams: SearchParams, expectedMatches: FindMatch[]): void {
let actual = TextModelSearch.findMatches(model, searchParams, model.getFullModelRange(), false, 1000);
assert.deepEqual(actual, expectedMatches, 'findMatches OK');
// test `findNextMatch`
let startPos = new Position(1, 1);
let match = TextModelSearch.findNextMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[0], `findNextMatch ${startPos}`);
for (let i = 0; i < expectedMatches.length; i++) {
startPos = expectedMatches[i].range.getStartPosition();
match = TextModelSearch.findNextMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[i], `findNextMatch ${startPos}`);
}
// test `findPrevMatch`
startPos = new Position(model.getLineCount(), model.getLineMaxColumn(model.getLineCount()));
match = TextModelSearch.findPreviousMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[expectedMatches.length - 1], `findPrevMatch ${startPos}`);
for (let i = 0; i < expectedMatches.length; i++) {
startPos = expectedMatches[i].range.getEndPosition();
match = TextModelSearch.findPreviousMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[i], `findPrevMatch ${startPos}`);
}
}
示例6: test
test('model insert text with one newline', () => {
thisModel.applyEdits([EditOperation.insert(new Position(1, 3), ' new line\nNo longer')]);
assert.equal(thisModel.getLineCount(), 6);
assert.equal(thisModel.getLineContent(1), 'My new line');
assert.equal(thisModel.getLineContent(2), 'No longer First Line');
});