more getlinelength. re #193427. (#194737)

* more getlinelength. re #193427.

* more 💄

* 💄
This commit is contained in:
Peng Lyu
2023-10-03 19:17:24 +01:00
committed by GitHub
parent 4204d34ed9
commit 34305abdce
6 changed files with 10 additions and 10 deletions
@@ -443,7 +443,7 @@ export class CursorMoveCommands {
for (let i = 0, len = cursors.length; i < len; i++) {
const cursor = cursors[i];
const viewLineNumber = cursor.viewState.position.lineNumber;
const halfLine = Math.round(viewModel.getLineContent(viewLineNumber).length / 2);
const halfLine = Math.round(viewModel.getLineLength(viewLineNumber) / 2);
result[i] = CursorState.fromViewState(MoveOperations.moveLeft(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, halfLine));
}
return result;
@@ -462,7 +462,7 @@ export class CursorMoveCommands {
for (let i = 0, len = cursors.length; i < len; i++) {
const cursor = cursors[i];
const viewLineNumber = cursor.viewState.position.lineNumber;
const halfLine = Math.round(viewModel.getLineContent(viewLineNumber).length / 2);
const halfLine = Math.round(viewModel.getLineLength(viewLineNumber) / 2);
result[i] = CursorState.fromViewState(MoveOperations.moveRight(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, halfLine));
}
return result;
@@ -160,8 +160,8 @@ export class TrimFinalNewLinesParticipant implements ITextFileSaveParticipant {
*/
private findLastNonEmptyLine(model: ITextModel): number {
for (let lineNumber = model.getLineCount(); lineNumber >= 1; lineNumber--) {
const lineContent = model.getLineContent(lineNumber);
if (lineContent.length > 0) {
const lineLength = model.getLineLength(lineNumber);
if (lineLength > 0) {
// this line has content
return lineNumber;
}
@@ -175,13 +175,13 @@ function getWordToLineNumbersMap(model: ITextModel | null): Map<string, number[]
// For every word in every line, map its ranges for fast lookup
for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
const lineContent = model.getLineContent(lineNumber);
const lineLength = model.getLineLength(lineNumber);
// If line is too long then skip the line
if (lineContent.length > MAX_TOKENIZATION_LINE_LEN) {
if (lineLength > MAX_TOKENIZATION_LINE_LEN) {
continue;
}
const lineContent = model.getLineContent(lineNumber);
model.tokenization.forceTokenization(lineNumber);
const lineTokens = model.tokenization.getLineTokens(lineNumber);
for (let tokenIndex = 0, tokenCount = lineTokens.getCount(); tokenIndex < tokenCount; tokenIndex++) {
@@ -506,7 +506,7 @@ export class InteractiveEditor extends EditorPane {
this._widgetDisposableStore.add(this._codeEditorWidget.onDidChangeCursorPosition(({ position }) => {
const viewModel = this._codeEditorWidget._getViewModel()!;
const lastLineNumber = viewModel.getLineCount();
const lastLineCol = viewModel.getLineContent(lastLineNumber).length + 1;
const lastLineCol = viewModel.getLineLength(lastLineNumber) + 1;
const viewPosition = viewModel.coordinatesConverter.convertModelPositionToViewPosition(position);
const firstLine = viewPosition.lineNumber === 1 && viewPosition.column === 1;
const lastLine = viewPosition.lineNumber === lastLineNumber && viewPosition.column === lastLineCol;
@@ -34,7 +34,7 @@ export class SmartSnippetInserter {
const eolLength = model.getEOL().length;
const lineCount = model.getLineCount();
for (let lineNumber = 1; lineNumber <= lineCount; lineNumber++) {
const lineTotalLength = model.getLineContent(lineNumber).length + eolLength;
const lineTotalLength = model.getLineLength(lineNumber) + eolLength;
const offsetAfterLine = offsetBeforeLine + lineTotalLength;
if (offsetAfterLine > offset) {
@@ -378,7 +378,7 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
// mark the untitled text editor as non-dirty once its content becomes empty and we do
// not have an associated path set. we never want dirty indicator in that case.
if (!this.hasAssociatedFilePath && textEditorModel.getLineCount() === 1 && textEditorModel.getLineContent(1) === '') {
if (!this.hasAssociatedFilePath && textEditorModel.getLineCount() === 1 && textEditorModel.getLineLength(1) === 0) {
this.setDirty(false);
}