|
5 | 5 | 'use strict'; |
6 | 6 |
|
7 | 7 | import * as assert from 'assert'; |
8 | | -import { Cursor } from 'vs/editor/common/controller/cursor'; |
9 | 8 | import { EditOperation } from 'vs/editor/common/core/editOperation'; |
10 | 9 | import { Position } from 'vs/editor/common/core/position'; |
11 | 10 | import { Range } from 'vs/editor/common/core/range'; |
12 | 11 | import { Selection } from 'vs/editor/common/core/selection'; |
13 | 12 | import { IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon'; |
14 | | -import { Model } from 'vs/editor/common/model/model'; |
15 | 13 | import { ILineEdit, ModelLine, LineMarker, MarkersTracker } from 'vs/editor/common/model/modelLine'; |
16 | | -import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; |
17 | | -import { viewModelHelper } from 'vs/editor/test/common/editorTestUtils'; |
| 14 | +import { withMockCodeEditor } from "vs/editor/test/common/mocks/mockCodeEditor"; |
18 | 15 |
|
19 | 16 | const NO_TAB_SIZE = 0; |
20 | 17 |
|
21 | 18 | function testCommand(lines: string[], selections: Selection[], edits: IIdentifiedSingleEditOperation[], expectedLines: string[], expectedSelections: Selection[]): void { |
22 | | - let model = Model.createFromString(lines.join('\n')); |
23 | | - let config = new TestConfiguration(null); |
24 | | - let cursor = new Cursor(config, model, viewModelHelper(model)); |
| 19 | + withMockCodeEditor(lines, {}, (editor, cursor) => { |
| 20 | + const model = editor.getModel(); |
25 | 21 |
|
26 | | - cursor.setSelections('tests', selections); |
| 22 | + cursor.setSelections('tests', selections); |
27 | 23 |
|
28 | | - model.applyEdits(edits); |
| 24 | + model.applyEdits(edits); |
29 | 25 |
|
30 | | - assert.deepEqual(model.getLinesContent(), expectedLines); |
| 26 | + assert.deepEqual(model.getLinesContent(), expectedLines); |
31 | 27 |
|
32 | | - let actualSelections = cursor.getSelections(); |
33 | | - assert.deepEqual(actualSelections.map(s => s.toString()), expectedSelections.map(s => s.toString())); |
| 28 | + let actualSelections = cursor.getSelections(); |
| 29 | + assert.deepEqual(actualSelections.map(s => s.toString()), expectedSelections.map(s => s.toString())); |
34 | 30 |
|
35 | | - cursor.dispose(); |
36 | | - config.dispose(); |
37 | | - model.dispose(); |
| 31 | + }); |
38 | 32 | } |
39 | 33 |
|
40 | 34 | function testLineEditMarker(text: string, column: number, stickToPreviousCharacter: boolean, edit: ILineEdit, expectedColumn: number): void { |
|
0 commit comments