未验证 提交 58aa1114 编写于 作者: A Alex Dima

Remove TextModel.createFromString

上级 147f417a
......@@ -37,9 +37,6 @@ import { Color } from 'vs/base/common/color';
import { Constants } from 'vs/base/common/uint';
import { EditorTheme } from 'vs/editor/common/view/viewContext';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { NoOpNotification, INotificationService } from 'vs/platform/notification/common/notification';
function createTextBufferBuilder() {
return new PieceTreeTextBufferBuilder();
......@@ -191,27 +188,6 @@ export class TextModel extends Disposable implements model.ITextModel {
largeFileOptimizations: EDITOR_MODEL_DEFAULTS.largeFileOptimizations,
};
public static createFromString(text: string, options: model.ITextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier | null = null, uri: URI | null = null): TextModel {
const dialogService = new class implements IDialogService {
_serviceBrand: undefined;
confirm() { return Promise.resolve({ confirmed: false }); }
show() { return Promise.resolve({ choice: 0 }); }
about() { return Promise.resolve(); }
};
const noop = new NoOpNotification();
const notificationService = new class implements INotificationService {
_serviceBrand: undefined;
info() { return noop; }
warn() { return noop; }
error() { return noop; }
notify() { return noop; }
prompt() { return noop; }
status() { return Disposable.None; }
setFilter() { }
};
return new TextModel(text, options, languageIdentifier, uri, new UndoRedoService(dialogService, notificationService));
}
public static resolveOptions(textBuffer: model.ITextBuffer, options: model.ITextModelCreationOptions): model.TextModelResolvedOptions {
if (options.detectIndentation) {
const guessedIndentation = guessIndentation(textBuffer, options.tabSize, options.insertSpaces);
......
......@@ -33,6 +33,7 @@ import * as peekView from 'vs/editor/contrib/peekView/peekView';
import { FileReferences, OneReference, ReferencesModel } from '../referencesModel';
import { FuzzyScore } from 'vs/base/common/filters';
import { SplitView, Sizing } from 'vs/base/browser/ui/splitview/splitview';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
class DecorationsManager implements IDisposable {
......@@ -215,7 +216,8 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
@ITextModelService private readonly _textModelResolverService: ITextModelService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@peekView.IPeekViewService private readonly _peekViewService: peekView.IPeekViewService,
@ILabelService private readonly _uriLabel: ILabelService
@ILabelService private readonly _uriLabel: ILabelService,
@IUndoRedoService private readonly _undoRedoService: IUndoRedoService,
) {
super(editor, { showFrame: false, showArrow: true, isResizeable: true, isAccessible: true });
......@@ -304,7 +306,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
};
this._preview = this._instantiationService.createInstance(EmbeddedCodeEditorWidget, this._previewContainer, options, this.editor);
dom.hide(this._previewContainer);
this._previewNotAvailableMessage = TextModel.createFromString(nls.localize('missingPreviewMessage', "no preview available"));
this._previewNotAvailableMessage = new TextModel(nls.localize('missingPreviewMessage', "no preview available"), TextModel.DEFAULT_CREATION_OPTIONS, null, null, this._undoRedoService);
// tree
this._treeContainer = dom.append(containerElement, dom.$('div.ref-tree.inline'));
......
......@@ -7,6 +7,9 @@ import { URI } from 'vs/base/common/uri';
import { DefaultEndOfLine, ITextModelCreationOptions } from 'vs/editor/common/model';
import { TextModel } from 'vs/editor/common/model/textModel';
import { LanguageIdentifier } from 'vs/editor/common/modes';
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
export function withEditorModel(text: string[], callback: (model: TextModel) => void): void {
let model = createTextModel(text.join('\n'));
......@@ -36,5 +39,8 @@ export function createTextModel(text: string, _options: IRelaxedTextModelCreatio
isForSimpleWidget: (typeof _options.isForSimpleWidget === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.isForSimpleWidget : _options.isForSimpleWidget),
largeFileOptimizations: (typeof _options.largeFileOptimizations === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.largeFileOptimizations : _options.largeFileOptimizations),
};
return TextModel.createFromString(text, options, languageIdentifier, uri);
const dialogService = new TestDialogService();
const notificationService = new TestNotificationService();
const undoRedoService = new UndoRedoService(dialogService, notificationService);
return new TextModel(text, options, languageIdentifier, uri, undoRedoService);
}
......@@ -26,6 +26,7 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { WorkspaceFileEdit } from 'vs/editor/common/modes';
import { compare } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
// --- VIEW MODEL
......@@ -174,7 +175,10 @@ export class BulkEditDataSource implements IAsyncDataSource<BulkFileOperations,
public groupByFile: boolean = true;
constructor(@ITextModelService private readonly _textModelService: ITextModelService) { }
constructor(
@ITextModelService private readonly _textModelService: ITextModelService,
@IUndoRedoService private readonly _undoRedoService: IUndoRedoService,
) { }
hasChildren(element: BulkFileOperations | BulkEditElement): boolean {
if (element instanceof FileElement) {
......@@ -210,7 +214,7 @@ export class BulkEditDataSource implements IAsyncDataSource<BulkFileOperations,
textModel = ref.object.textEditorModel;
textModelDisposable = ref;
} catch {
textModel = TextModel.createFromString('');
textModel = new TextModel('', TextModel.DEFAULT_CREATION_OPTIONS, null, null, this._undoRedoService);
textModelDisposable = textModel;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册