mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 17:23:29 -05:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -28,7 +28,6 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
private _languageId: string;
|
||||
private _isDirty: boolean;
|
||||
private _document?: vscode.TextDocument;
|
||||
private _textLines: vscode.TextLine[] = [];
|
||||
private _isDisposed: boolean = false;
|
||||
|
||||
constructor(proxy: MainThreadDocumentsShape, uri: URI, lines: string[], eol: string,
|
||||
@@ -130,33 +129,11 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
line = lineOrPosition;
|
||||
}
|
||||
|
||||
if (typeof line !== 'number' || line < 0 || line >= this._lines.length) {
|
||||
if (typeof line !== 'number' || line < 0 || line >= this._lines.length || Math.floor(line) !== line) {
|
||||
throw new Error('Illegal value for `line`');
|
||||
}
|
||||
|
||||
let result = this._textLines[line];
|
||||
if (!result || result.lineNumber !== line || result.text !== this._lines[line]) {
|
||||
|
||||
const text = this._lines[line];
|
||||
const firstNonWhitespaceCharacterIndex = /^(\s*)/.exec(text)![1].length;
|
||||
const range = new Range(line, 0, line, text.length);
|
||||
const rangeIncludingLineBreak = line < this._lines.length - 1
|
||||
? new Range(line, 0, line + 1, 0)
|
||||
: range;
|
||||
|
||||
result = Object.freeze({
|
||||
lineNumber: line,
|
||||
range,
|
||||
rangeIncludingLineBreak,
|
||||
text,
|
||||
firstNonWhitespaceCharacterIndex, //TODO@api, rename to 'leadingWhitespaceLength'
|
||||
isEmptyOrWhitespace: firstNonWhitespaceCharacterIndex === text.length
|
||||
});
|
||||
|
||||
this._textLines[line] = result;
|
||||
}
|
||||
|
||||
return result;
|
||||
return new ExtHostDocumentLine(line, this._lines[line], line === this._lines.length - 1);
|
||||
}
|
||||
|
||||
private _offsetAt(position: vscode.Position): number {
|
||||
@@ -239,8 +216,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
|
||||
} else if (regExpLeadsToEndlessLoop(regexp)) {
|
||||
// use default when custom-regexp is bad
|
||||
console.warn(`[getWordRangeAtPosition]: ignoring custom regexp '${regexp.source}' because it matches the empty string.`);
|
||||
regexp = getWordDefinitionFor(this._languageId);
|
||||
throw new Error(`[getWordRangeAtPosition]: ignoring custom regexp '${regexp.source}' because it matches the empty string.`);
|
||||
}
|
||||
|
||||
const wordAtText = getWordAtText(
|
||||
@@ -256,3 +232,44 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class ExtHostDocumentLine implements vscode.TextLine {
|
||||
|
||||
private readonly _line: number;
|
||||
private readonly _text: string;
|
||||
private readonly _isLastLine: boolean;
|
||||
|
||||
constructor(line: number, text: string, isLastLine: boolean) {
|
||||
this._line = line;
|
||||
this._text = text;
|
||||
this._isLastLine = isLastLine;
|
||||
}
|
||||
|
||||
public get lineNumber(): number {
|
||||
return this._line;
|
||||
}
|
||||
|
||||
public get text(): string {
|
||||
return this._text;
|
||||
}
|
||||
|
||||
public get range(): Range {
|
||||
return new Range(this._line, 0, this._line, this._text.length);
|
||||
}
|
||||
|
||||
public get rangeIncludingLineBreak(): Range {
|
||||
if (this._isLastLine) {
|
||||
return this.range;
|
||||
}
|
||||
return new Range(this._line, 0, this._line + 1, 0);
|
||||
}
|
||||
|
||||
public get firstNonWhitespaceCharacterIndex(): number {
|
||||
//TODO@api, rename to 'leadingWhitespaceLength'
|
||||
return /^(\s*)/.exec(this._text)![1].length;
|
||||
}
|
||||
|
||||
public get isEmptyOrWhitespace(): boolean {
|
||||
return this.firstNonWhitespaceCharacterIndex === this._text.length;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user