@@ -11,7 +11,7 @@ import { Selection } from 'vs/editor/common/core/selection';
11
11
import { Handler } from 'vs/editor/common/editorCommon' ;
12
12
import { ITextModel } from 'vs/editor/common/model' ;
13
13
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl' ;
14
- import { DeleteAllLeftAction , DeleteAllRightAction , DeleteLinesAction , IndentLinesAction , InsertLineAfterAction , InsertLineBeforeAction , JoinLinesAction , LowerCaseAction , SnakeCaseAction , SortLinesAscendingAction , SortLinesDescendingAction , TitleCaseAction , TransposeAction , UpperCaseAction } from 'vs/editor/contrib/linesOperations/linesOperations' ;
14
+ import { DeleteAllLeftAction , DeleteAllRightAction , DeleteDuplicateLinesAction , DeleteLinesAction , IndentLinesAction , InsertLineAfterAction , InsertLineBeforeAction , JoinLinesAction , LowerCaseAction , SnakeCaseAction , SortLinesAscendingAction , SortLinesDescendingAction , TitleCaseAction , TransposeAction , UpperCaseAction } from 'vs/editor/contrib/linesOperations/linesOperations' ;
15
15
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor' ;
16
16
import { createTextModel } from 'vs/editor/test/common/editorTestUtils' ;
17
17
@@ -143,6 +143,67 @@ suite('Editor Contrib - Line Operations', () => {
143
143
} ) ;
144
144
} ) ;
145
145
146
+ suite ( 'DeleteDuplicateLinesAction' , ( ) => {
147
+ test ( 'should remove duplicate lines' , function ( ) {
148
+ withTestCodeEditor (
149
+ [
150
+ 'alpha' ,
151
+ 'beta' ,
152
+ 'beta' ,
153
+ 'beta' ,
154
+ 'alpha' ,
155
+ 'omicron' ,
156
+ ] , { } , ( editor ) => {
157
+ let model = editor . getModel ( ) ! ;
158
+ let deleteDuplicateLinesAction = new DeleteDuplicateLinesAction ( ) ;
159
+
160
+ editor . setSelection ( new Selection ( 1 , 3 , 6 , 4 ) ) ;
161
+ executeAction ( deleteDuplicateLinesAction , editor ) ;
162
+ assert . deepStrictEqual ( model . getLinesContent ( ) , [
163
+ 'alpha' ,
164
+ 'beta' ,
165
+ 'omicron' ,
166
+ ] ) ;
167
+ assertSelection ( editor , new Selection ( 1 , 1 , 3 , 7 ) ) ;
168
+ } ) ;
169
+ } ) ;
170
+
171
+ test ( 'should remove duplicate lines in multiple selections' , function ( ) {
172
+ withTestCodeEditor (
173
+ [
174
+ 'alpha' ,
175
+ 'beta' ,
176
+ 'beta' ,
177
+ 'omicron' ,
178
+ '' ,
179
+ 'alpha' ,
180
+ 'alpha' ,
181
+ 'beta'
182
+ ] , { } , ( editor ) => {
183
+ let model = editor . getModel ( ) ! ;
184
+ let deleteDuplicateLinesAction = new DeleteDuplicateLinesAction ( ) ;
185
+
186
+ editor . setSelections ( [ new Selection ( 1 , 2 , 4 , 3 ) , new Selection ( 6 , 2 , 8 , 3 ) ] ) ;
187
+ executeAction ( deleteDuplicateLinesAction , editor ) ;
188
+ assert . deepStrictEqual ( model . getLinesContent ( ) , [
189
+ 'alpha' ,
190
+ 'beta' ,
191
+ 'omicron' ,
192
+ '' ,
193
+ 'alpha' ,
194
+ 'beta'
195
+ ] ) ;
196
+ let expectedSelections = [
197
+ new Selection ( 1 , 1 , 3 , 7 ) ,
198
+ new Selection ( 5 , 1 , 6 , 4 )
199
+ ] ;
200
+ editor . getSelections ( ) ! . forEach ( ( actualSelection , index ) => {
201
+ assert . deepStrictEqual ( actualSelection . toString ( ) , expectedSelections [ index ] . toString ( ) ) ;
202
+ } ) ;
203
+ } ) ;
204
+ } ) ;
205
+ } ) ;
206
+
146
207
147
208
suite ( 'DeleteAllLeftAction' , ( ) => {
148
209
test ( 'should delete to the left of the cursor' , function ( ) {
0 commit comments