mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 05fc61ffb1aee9fd19173c32113daed079f9b7bd (#5074)
* Merge from vscode 05fc61ffb1aee9fd19173c32113daed079f9b7bd * fix tests
This commit is contained in:
@@ -13,7 +13,6 @@ import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { IModelContentChange, IModelContentChangedEvent, IModelDecorationsChangedEvent, IModelLanguageChangedEvent, IModelLanguageConfigurationChangedEvent, IModelOptionsChangedEvent, IModelTokensChangedEvent, ModelRawContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { SearchData } from 'vs/editor/common/model/textModelSearch';
|
||||
import { LanguageId, LanguageIdentifier, FormattingOptions } from 'vs/editor/common/modes';
|
||||
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
import { ThemeColor } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
/**
|
||||
@@ -460,6 +459,17 @@ export interface IActiveIndentGuideInfo {
|
||||
indent: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text snapshot that works like an iterator.
|
||||
* Will try to return chunks of roughly ~64KB size.
|
||||
* Will return null when finished.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface ITextSnapshot {
|
||||
read(): string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A model.
|
||||
*/
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { FindMatch } from 'vs/editor/common/model';
|
||||
import { FindMatch, ITextSnapshot } from 'vs/editor/common/model';
|
||||
import { NodeColor, SENTINEL, TreeNode, fixInsert, leftest, rbDelete, righttest, updateTreeMetadata } from 'vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase';
|
||||
import { SearchData, Searcher, createFindMatch, isValidMatch } from 'vs/editor/common/model/textModelSearch';
|
||||
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
|
||||
// const lfRegex = new RegExp(/\r\n|\r|\n/g);
|
||||
export const AverageBufferSize = 65535;
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ApplyEditsResult, EndOfLinePreference, FindMatch, IIdentifiedSingleEditOperation, IInternalModelContentChange, ISingleEditOperationIdentifier, ITextBuffer } from 'vs/editor/common/model';
|
||||
import { ApplyEditsResult, EndOfLinePreference, FindMatch, IIdentifiedSingleEditOperation, IInternalModelContentChange, ISingleEditOperationIdentifier, ITextBuffer, ITextSnapshot } from 'vs/editor/common/model';
|
||||
import { PieceTreeBase, StringBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase';
|
||||
import { SearchData } from 'vs/editor/common/model/textModelSearch';
|
||||
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
|
||||
export interface IValidatedEditOperation {
|
||||
sortIndex: number;
|
||||
|
||||
@@ -30,9 +30,9 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo
|
||||
import { NULL_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/nullMode';
|
||||
import { ignoreBracketsInToken } from 'vs/editor/common/modes/supports';
|
||||
import { BracketsUtils, RichEditBracket, RichEditBrackets } from 'vs/editor/common/modes/supports/richEditBrackets';
|
||||
import { IStringStream, ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
import { ITheme, ThemeColor } from 'vs/platform/theme/common/themeService';
|
||||
import { withUndefinedAsNull } from 'vs/base/common/types';
|
||||
import { VSBufferReadableStream, VSBuffer } from 'vs/base/common/buffer';
|
||||
|
||||
const CHEAP_TOKENIZATION_LENGTH_LIMIT = 2048;
|
||||
|
||||
@@ -46,36 +46,54 @@ export function createTextBufferFactory(text: string): model.ITextBufferFactory
|
||||
return builder.finish();
|
||||
}
|
||||
|
||||
export function createTextBufferFactoryFromStream(stream: IStringStream, filter?: (chunk: string) => string): Promise<model.ITextBufferFactory> {
|
||||
return new Promise<model.ITextBufferFactory>((c, e) => {
|
||||
let done = false;
|
||||
let builder = createTextBufferBuilder();
|
||||
interface ITextStream {
|
||||
on(event: 'data', callback: (data: string) => void): void;
|
||||
on(event: 'error', callback: (err: Error) => void): void;
|
||||
on(event: 'end', callback: () => void): void;
|
||||
on(event: string, callback: any): void;
|
||||
}
|
||||
|
||||
export function createTextBufferFactoryFromStream(stream: ITextStream, filter?: (chunk: string) => string, validator?: (chunk: string) => Error | undefined): Promise<model.ITextBufferFactory>;
|
||||
export function createTextBufferFactoryFromStream(stream: VSBufferReadableStream, filter?: (chunk: VSBuffer) => VSBuffer, validator?: (chunk: VSBuffer) => Error | undefined): Promise<model.ITextBufferFactory>;
|
||||
export function createTextBufferFactoryFromStream(stream: ITextStream | VSBufferReadableStream, filter?: (chunk: any) => string | VSBuffer, validator?: (chunk: any) => Error | undefined): Promise<model.ITextBufferFactory> {
|
||||
return new Promise<model.ITextBufferFactory>((resolve, reject) => {
|
||||
const builder = createTextBufferBuilder();
|
||||
|
||||
let done = false;
|
||||
|
||||
stream.on('data', (chunk: string | VSBuffer) => {
|
||||
if (validator) {
|
||||
const error = validator(chunk);
|
||||
if (error) {
|
||||
done = true;
|
||||
reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
stream.on('data', (chunk) => {
|
||||
if (filter) {
|
||||
chunk = filter(chunk);
|
||||
}
|
||||
|
||||
builder.acceptChunk(chunk);
|
||||
builder.acceptChunk((typeof chunk === 'string') ? chunk : chunk.toString());
|
||||
});
|
||||
|
||||
stream.on('error', (error) => {
|
||||
if (!done) {
|
||||
done = true;
|
||||
e(error);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('end', () => {
|
||||
if (!done) {
|
||||
done = true;
|
||||
c(builder.finish());
|
||||
resolve(builder.finish());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function createTextBufferFactoryFromSnapshot(snapshot: ITextSnapshot): model.ITextBufferFactory {
|
||||
export function createTextBufferFactoryFromSnapshot(snapshot: model.ITextSnapshot): model.ITextBufferFactory {
|
||||
let builder = createTextBufferBuilder();
|
||||
|
||||
let chunk: string | null;
|
||||
@@ -111,12 +129,12 @@ function singleLetter(result: number): string {
|
||||
const LIMIT_FIND_COUNT = 999;
|
||||
export const LONG_LINE_BOUNDARY = 10000;
|
||||
|
||||
class TextModelSnapshot implements ITextSnapshot {
|
||||
class TextModelSnapshot implements model.ITextSnapshot {
|
||||
|
||||
private readonly _source: ITextSnapshot;
|
||||
private readonly _source: model.ITextSnapshot;
|
||||
private _eos: boolean;
|
||||
|
||||
constructor(source: ITextSnapshot) {
|
||||
constructor(source: model.ITextSnapshot) {
|
||||
this._source = source;
|
||||
this._eos = false;
|
||||
}
|
||||
@@ -731,7 +749,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
return fullModelValue;
|
||||
}
|
||||
|
||||
public createSnapshot(preserveBOM: boolean = false): ITextSnapshot {
|
||||
public createSnapshot(preserveBOM: boolean = false): model.ITextSnapshot {
|
||||
return new TextModelSnapshot(this._buffer.createSnapshot(preserveBOM));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { SelectionBasedVariableResolver, CompositeSnippetVariableResolver, Model
|
||||
import { SnippetParser, Variable, VariableResolver } from 'vs/editor/contrib/snippet/snippetParser';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { Workspace, toWorkspaceFolders, IWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { Workspace, toWorkspaceFolders, IWorkspace, IWorkspaceContextService, toWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
suite('Snippet Variables Resolver', function () {
|
||||
|
||||
@@ -328,11 +328,12 @@ suite('Snippet Variables Resolver', function () {
|
||||
assertVariableResolve(resolver, 'WORKSPACE_NAME', undefined);
|
||||
|
||||
// single folder workspace without config
|
||||
workspace = new Workspace('', toWorkspaceFolders([{ path: '/folderName' }]));
|
||||
workspace = new Workspace('', [toWorkspaceFolder(URI.file('/folderName'))]);
|
||||
assertVariableResolve(resolver, 'WORKSPACE_NAME', 'folderName');
|
||||
|
||||
// workspace with config
|
||||
workspace = new Workspace('', toWorkspaceFolders([{ path: 'folderName' }]), URI.file('testWorkspace.code-workspace'));
|
||||
const workspaceConfigPath = URI.file('testWorkspace.code-workspace');
|
||||
workspace = new Workspace('', toWorkspaceFolders([{ path: 'folderName' }], workspaceConfigPath), workspaceConfigPath);
|
||||
assertVariableResolve(resolver, 'WORKSPACE_NAME', 'testWorkspace');
|
||||
});
|
||||
});
|
||||
@@ -7,14 +7,13 @@ import * as assert from 'assert';
|
||||
import { WordCharacterClassifier } from 'vs/editor/common/controller/wordCharacterClassifier';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { DefaultEndOfLine, ITextSnapshot } from 'vs/editor/common/model';
|
||||
import { PieceTreeBase } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase';
|
||||
import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||
import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';
|
||||
import { NodeColor, SENTINEL, TreeNode } from 'vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { SearchData } from 'vs/editor/common/model/textModelSearch';
|
||||
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
|
||||
const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user