@@ -14,39 +14,42 @@ import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/browser/move
14
14
import { testCommand } from 'vs/editor/test/browser/testCommand' ;
15
15
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService' ;
16
16
17
+ const enum MoveLinesDirection {
18
+ Up ,
19
+ Down
20
+ }
21
+
17
22
function testMoveLinesDownCommand ( lines : string [ ] , selection : Selection , expectedLines : string [ ] , expectedSelection : Selection , languageConfigurationService ?: ILanguageConfigurationService ) : void {
18
- const disposables = new DisposableStore ( ) ;
19
- if ( ! languageConfigurationService ) {
20
- languageConfigurationService = disposables . add ( new TestLanguageConfigurationService ( ) ) ;
21
- }
22
- testCommand ( lines , null , selection , ( accessor , sel ) => new MoveLinesCommand ( sel , true , EditorAutoIndentStrategy . Advanced , languageConfigurationService ) , expectedLines , expectedSelection ) ;
23
- disposables . dispose ( ) ;
23
+ testMoveLinesUpOrDownCommand ( MoveLinesDirection . Down , lines , selection , expectedLines , expectedSelection , languageConfigurationService ) ;
24
24
}
25
25
26
26
function testMoveLinesUpCommand ( lines : string [ ] , selection : Selection , expectedLines : string [ ] , expectedSelection : Selection , languageConfigurationService ?: ILanguageConfigurationService ) : void {
27
- const disposables = new DisposableStore ( ) ;
28
- if ( ! languageConfigurationService ) {
29
- languageConfigurationService = disposables . add ( new TestLanguageConfigurationService ( ) ) ;
30
- }
31
- testCommand ( lines , null , selection , ( accessor , sel ) => new MoveLinesCommand ( sel , false , EditorAutoIndentStrategy . Advanced , languageConfigurationService ) , expectedLines , expectedSelection ) ;
32
- disposables . dispose ( ) ;
27
+ testMoveLinesUpOrDownCommand ( MoveLinesDirection . Up , lines , selection , expectedLines , expectedSelection , languageConfigurationService ) ;
33
28
}
34
29
35
30
function testMoveLinesDownWithIndentCommand ( languageId : string , lines : string [ ] , selection : Selection , expectedLines : string [ ] , expectedSelection : Selection , languageConfigurationService ?: ILanguageConfigurationService ) : void {
31
+ testMoveLinesUpOrDownWithIndentCommand ( MoveLinesDirection . Down , languageId , lines , selection , expectedLines , expectedSelection , languageConfigurationService ) ;
32
+ }
33
+
34
+ function testMoveLinesUpWithIndentCommand ( languageId : string , lines : string [ ] , selection : Selection , expectedLines : string [ ] , expectedSelection : Selection , languageConfigurationService ?: ILanguageConfigurationService ) : void {
35
+ testMoveLinesUpOrDownWithIndentCommand ( MoveLinesDirection . Up , languageId , lines , selection , expectedLines , expectedSelection , languageConfigurationService ) ;
36
+ }
37
+
38
+ function testMoveLinesUpOrDownCommand ( direction : MoveLinesDirection , lines : string [ ] , selection : Selection , expectedLines : string [ ] , expectedSelection : Selection , languageConfigurationService ?: ILanguageConfigurationService ) {
36
39
const disposables = new DisposableStore ( ) ;
37
40
if ( ! languageConfigurationService ) {
38
41
languageConfigurationService = disposables . add ( new TestLanguageConfigurationService ( ) ) ;
39
42
}
40
- testCommand ( lines , languageId , selection , ( accessor , sel ) => new MoveLinesCommand ( sel , true , EditorAutoIndentStrategy . Full , languageConfigurationService ) , expectedLines , expectedSelection ) ;
43
+ testCommand ( lines , null , selection , ( accessor , sel ) => new MoveLinesCommand ( sel , direction === MoveLinesDirection . Up ? false : true , EditorAutoIndentStrategy . Advanced , languageConfigurationService ) , expectedLines , expectedSelection ) ;
41
44
disposables . dispose ( ) ;
42
45
}
43
46
44
- function testMoveLinesUpWithIndentCommand ( languageId : string , lines : string [ ] , selection : Selection , expectedLines : string [ ] , expectedSelection : Selection , languageConfigurationService ?: ILanguageConfigurationService ) : void {
47
+ function testMoveLinesUpOrDownWithIndentCommand ( direction : MoveLinesDirection , languageId : string , lines : string [ ] , selection : Selection , expectedLines : string [ ] , expectedSelection : Selection , languageConfigurationService ?: ILanguageConfigurationService ) {
45
48
const disposables = new DisposableStore ( ) ;
46
49
if ( ! languageConfigurationService ) {
47
50
languageConfigurationService = disposables . add ( new TestLanguageConfigurationService ( ) ) ;
48
51
}
49
- testCommand ( lines , languageId , selection , ( accessor , sel ) => new MoveLinesCommand ( sel , false , EditorAutoIndentStrategy . Full , languageConfigurationService ) , expectedLines , expectedSelection ) ;
52
+ testCommand ( lines , languageId , selection , ( accessor , sel ) => new MoveLinesCommand ( sel , direction === MoveLinesDirection . Up ? false : true , EditorAutoIndentStrategy . Full , languageConfigurationService ) , expectedLines , expectedSelection ) ;
50
53
disposables . dispose ( ) ;
51
54
}
52
55
0 commit comments