本文整理汇总了TypeScript中vs/editor/common/model/model.Model.createFromString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Model.createFromString方法的具体用法?TypeScript Model.createFromString怎么用?TypeScript Model.createFromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/model/model.Model
的用法示例。
在下文中一共展示了Model.createFromString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Cannot use "<?php" as user snippet prefix anymore, #26275', async function () {
snippetService = new SimpleSnippetService([{
prefix: '<?php',
codeSnippet: 'insert me',
name: '',
description: '',
source: ''
}]);
const provider = new SnippetSuggestProvider(modeService, snippetService);
let model = Model.createFromString('\t<?php', undefined, modeService.getLanguageIdentifier('fooLang'));
let result = await provider.provideCompletionItems(model, new Position(1, 7));
assert.equal(result.suggestions.length, 1);
model.dispose();
model = Model.createFromString('\t<?', undefined, modeService.getLanguageIdentifier('fooLang'));
result = await provider.provideCompletionItems(model, new Position(1, 4));
assert.equal(result.suggestions.length, 1);
model.dispose();
model = Model.createFromString('a<?', undefined, modeService.getLanguageIdentifier('fooLang'));
result = await provider.provideCompletionItems(model, new Position(1, 4));
assert.equal(result.suggestions.length, 0);
model.dispose();
});
示例2: test
test('editor variables, file/dir', function () {
assert.equal(resolver.resolve('TM_FILENAME'), 'text.txt');
if (!isWindows) {
assert.equal(resolver.resolve('TM_DIRECTORY'), '/foo/files');
assert.equal(resolver.resolve('TM_FILEPATH'), '/foo/files/text.txt');
}
resolver = new EditorSnippetVariableResolver(
Model.createFromString('', undefined, undefined, URI.parse('http://www.pb.o/abc/def/ghi')),
new Selection(1, 1, 1, 1)
);
assert.equal(resolver.resolve('TM_FILENAME'), 'ghi');
if (!isWindows) {
assert.equal(resolver.resolve('TM_DIRECTORY'), '/abc/def');
assert.equal(resolver.resolve('TM_FILEPATH'), '/abc/def/ghi');
}
resolver = new EditorSnippetVariableResolver(
Model.createFromString('', undefined, undefined, URI.parse('mem:fff.ts')),
new Selection(1, 1, 1, 1)
);
assert.equal(resolver.resolve('TM_DIRECTORY'), '');
assert.equal(resolver.resolve('TM_FILEPATH'), 'fff.ts');
});
示例3: test
test('Bug 18276:[editor] Indentation broken when selection is empty', () => {
let model = Model.createFromString(
[
'function baz() {'
].join('\n'),
{
defaultEOL: DefaultEndOfLine.LF,
detectIndentation: false,
insertSpaces: false,
tabSize: 4,
trimAutoWhitespace: true
}
);
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
let indentLinesAction = new IndentLinesAction();
editor.setPosition(new Position(1, 2));
indentLinesAction.run(null, editor);
assert.equal(model.getLineContent(1), '\tfunction baz() {');
assert.deepEqual(editor.getSelection(), new Selection(1, 3, 1, 3));
CoreEditingCommands.Tab.runEditorCommand(null, editor, null);
assert.equal(model.getLineContent(1), '\tf\tunction baz() {');
});
model.dispose();
});
示例4: assertRanges
function assertRanges(lines: string[], expected:IFoldingRange[]): void {
let model = Model.createFromString(lines.join('\n'));
let actual = computeRanges(model);
actual.sort((r1, r2) => r1.startLineNumber - r2.startLineNumber);
assert.deepEqual(actual, expected);
model.dispose();
}
示例5: testViewModel
export function testViewModel(text: string[], options: MockCodeEditorCreationOptions, callback: (viewModel: ViewModel, model: Model) => void): void {
const EDITOR_ID = 1;
let configuration = new TestConfiguration(options);
let model = Model.createFromString(text.join('\n'));
let factory = new CharacterHardWrappingLineMapperFactory(
configuration.editor.wrappingInfo.wordWrapBreakBeforeCharacters,
configuration.editor.wrappingInfo.wordWrapBreakAfterCharacters,
configuration.editor.wrappingInfo.wordWrapBreakObtrusiveCharacters
);
let linesCollection = new SplitLinesCollection(
model,
factory,
model.getOptions().tabSize,
configuration.editor.wrappingInfo.wrappingColumn,
configuration.editor.fontInfo.typicalFullwidthCharacterWidth / configuration.editor.fontInfo.typicalHalfwidthCharacterWidth,
configuration.editor.wrappingInfo.wrappingIndent
);
let viewModel = new ViewModel(
linesCollection,
EDITOR_ID,
configuration,
model
);
callback(viewModel, model);
viewModel.dispose();
model.dispose();
configuration.dispose();
}
示例6: test
test('_computeEdits EOL changed', function () {
const model = Model.createFromString(
[
'This is line one', //16
'and this is line number two', //27
'it is followed by #3', //20
'and finished with the fourth.', //29
].join('\n')
);
const textSource = TextSource.fromString(
[
'This is line one', //16
'and this is line number two', //27
'it is followed by #3', //20
'and finished with the fourth.', //29
].join('\r\n'),
DefaultEndOfLine.LF
);
const actual = ModelServiceImpl._computeEdits(model, textSource);
assert.deepEqual(actual, []);
});
示例7: Position
}).then(result => {
assert.equal(result.suggestions.length, 1);
model.dispose();
model = Model.createFromString('a<?', undefined, modeService.getLanguageIdentifier('fooLang'));
return provider.provideCompletionItems(model, new Position(1, 4));
}).then(result => {
示例8: test
test('issue #16922: Clicking on link doesn\'t seem to do anything', () => {
var model = Model.createFromString([
'Hello world,',
'How are you?',
'Fine.',
'Good.',
].join('\n'));
model.deltaDecorations([], [
{ range: new Range(1, 1, 1, 1), options: { className: '1' } },
{ range: new Range(1, 13, 1, 13), options: { className: '2' } },
{ range: new Range(2, 1, 2, 1), options: { className: '3' } },
{ range: new Range(2, 1, 2, 4), options: { className: '4' } },
{ range: new Range(2, 8, 2, 13), options: { className: '5' } },
{ range: new Range(3, 1, 4, 6), options: { className: '6' } },
{ range: new Range(1, 1, 3, 6), options: { className: 'x1' } },
{ range: new Range(2, 5, 2, 8), options: { className: 'x2' } },
{ range: new Range(1, 1, 2, 8), options: { className: 'x3' } },
{ range: new Range(2, 5, 3, 1), options: { className: 'x4' } },
]);
let inRange = model.getDecorationsInRange(new Range(2, 6, 2, 6));
let inRangeClassNames = inRange.map(d => d.options.className);
inRangeClassNames.sort();
assert.deepEqual(inRangeClassNames, ['x1', 'x2', 'x3', 'x4']);
model.dispose();
});