Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes https://github.com/microsoft/monaco-editor/issues/3920 #183960

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/vs/editor/browser/view/viewLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
import * as viewEvents from 'vs/editor/common/viewEvents';
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { BugIndicatingError } from 'vs/base/common/errors';

/**
* Represents a visible line
Expand Down Expand Up @@ -80,7 +81,7 @@ export class RenderedLinesCollection<T extends ILine> {
public getLine(lineNumber: number): T {
const lineIndex = lineNumber - this._rendLineNumberStart;
if (lineIndex < 0 || lineIndex >= this._lines.length) {
throw new Error('Illegal value for lineNumber');
throw new BugIndicatingError('Illegal value for lineNumber');
}
return this._lines[lineIndex];
}
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/common/model/guidesTextModelPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { TextModelPart } from 'vs/editor/common/model/textModelPart';
import { computeIndentLevel } from 'vs/editor/common/model/utils';
import { ILanguageConfigurationService, ResolvedLanguageConfiguration } from 'vs/editor/common/languages/languageConfigurationRegistry';
import { BracketGuideOptions, HorizontalGuidesState, IActiveIndentGuideInfo, IGuidesTextModelPart, IndentGuide, IndentGuideHorizontalLine } from 'vs/editor/common/textModelGuides';
import { BugIndicatingError } from 'vs/base/common/errors';

export class GuidesTextModelPart extends TextModelPart implements IGuidesTextModelPart {
constructor(
Expand Down Expand Up @@ -46,7 +47,7 @@ export class GuidesTextModelPart extends TextModelPart implements IGuidesTextMod
const lineCount = this.textModel.getLineCount();

if (lineNumber < 1 || lineNumber > lineCount) {
throw new Error('Illegal value for lineNumber');
throw new BugIndicatingError('Illegal value for lineNumber');
}

const foldingRules = this.getLanguageConfiguration(
Expand Down
12 changes: 6 additions & 6 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ArrayQueue, pushMany } from 'vs/base/common/arrays';
import { VSBuffer, VSBufferReadableStream } from 'vs/base/common/buffer';
import { Color } from 'vs/base/common/color';
import { illegalArgument, onUnexpectedError } from 'vs/base/common/errors';
import { BugIndicatingError, illegalArgument, onUnexpectedError } from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { combinedDisposable, Disposable, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -792,7 +792,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
public getLineContent(lineNumber: number): string {
this._assertNotDisposed();
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
throw new Error('Illegal value for lineNumber');
throw new BugIndicatingError('Illegal value for lineNumber');
}

return this._buffer.getLineContent(lineNumber);
Expand All @@ -801,7 +801,7 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
public getLineLength(lineNumber: number): number {
this._assertNotDisposed();
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
throw new Error('Illegal value for lineNumber');
throw new BugIndicatingError('Illegal value for lineNumber');
}

return this._buffer.getLineLength(lineNumber);
Expand Down Expand Up @@ -834,23 +834,23 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
public getLineMaxColumn(lineNumber: number): number {
this._assertNotDisposed();
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
throw new Error('Illegal value for lineNumber');
throw new BugIndicatingError('Illegal value for lineNumber');
}
return this._buffer.getLineLength(lineNumber) + 1;
}

public getLineFirstNonWhitespaceColumn(lineNumber: number): number {
this._assertNotDisposed();
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
throw new Error('Illegal value for lineNumber');
throw new BugIndicatingError('Illegal value for lineNumber');
}
return this._buffer.getLineFirstNonWhitespaceColumn(lineNumber);
}

public getLineLastNonWhitespaceColumn(lineNumber: number): number {
this._assertNotDisposed();
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
throw new Error('Illegal value for lineNumber');
throw new BugIndicatingError('Illegal value for lineNumber');
}
return this._buffer.getLineLastNonWhitespaceColumn(lineNumber);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/model/tokenizationTextModelPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ class GrammarTokens extends Disposable {
return;
}

startLineNumber = Math.max(1, startLineNumber);
startLineNumber = Math.max(1, Math.min(this._textModel.getLineCount(), startLineNumber));
endLineNumber = Math.min(this._textModel.getLineCount(), endLineNumber);

const builder = new ContiguousMultilineTokensBuilder();
Expand Down