@@ -9,7 +9,7 @@ import { Position } from 'vs/editor/common/core/position';
99import { Selection } from 'vs/editor/common/core/selection' ;
1010import { Handler } from 'vs/editor/common/editorCommon' ;
1111import { ITextModel } from 'vs/editor/common/model' ;
12- import { DeleteAllLeftAction , DeleteAllRightAction , IndentLinesAction , InsertLineAfterAction , InsertLineBeforeAction , JoinLinesAction , LowerCaseAction , SortLinesAscendingAction , SortLinesDescendingAction , TransposeAction , UpperCaseAction , DeleteLinesAction } from 'vs/editor/contrib/linesOperations/linesOperations' ;
12+ import { TitleCaseAction , DeleteAllLeftAction , DeleteAllRightAction , IndentLinesAction , InsertLineAfterAction , InsertLineBeforeAction , JoinLinesAction , LowerCaseAction , SortLinesAscendingAction , SortLinesDescendingAction , TransposeAction , UpperCaseAction , DeleteLinesAction } from 'vs/editor/contrib/linesOperations/linesOperations' ;
1313import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor' ;
1414import { createTextModel } from 'vs/editor/test/common/editorTestUtils' ;
1515
@@ -529,6 +529,7 @@ suite('Editor Contrib - Line Operations', () => {
529529 let model = editor . getModel ( ) ! ;
530530 let uppercaseAction = new UpperCaseAction ( ) ;
531531 let lowercaseAction = new LowerCaseAction ( ) ;
532+ let titlecaseAction = new TitleCaseAction ( ) ;
532533
533534 editor . setSelection ( new Selection ( 1 , 1 , 1 , 12 ) ) ;
534535 uppercaseAction . run ( null ! , editor ) ;
@@ -550,15 +551,63 @@ suite('Editor Contrib - Line Operations', () => {
550551 assert . equal ( model . getLineContent ( 1 ) , 'hello world' , '007' ) ;
551552 assert . deepEqual ( editor . getSelection ( ) ! . toString ( ) , new Selection ( 1 , 4 , 1 , 4 ) . toString ( ) , '008' ) ;
552553
554+ editor . setSelection ( new Selection ( 1 , 1 , 1 , 12 ) ) ;
555+ titlecaseAction . run ( null ! , editor ) ;
556+ assert . equal ( model . getLineContent ( 1 ) , 'Hello World' , '009' ) ;
557+ assert . deepEqual ( editor . getSelection ( ) ! . toString ( ) , new Selection ( 1 , 1 , 1 , 12 ) . toString ( ) , '010' ) ;
558+
553559 editor . setSelection ( new Selection ( 2 , 1 , 2 , 6 ) ) ;
554560 uppercaseAction . run ( null ! , editor ) ;
555- assert . equal ( model . getLineContent ( 2 ) , 'ÖÇŞĞÜ' , '009 ' ) ;
556- assert . deepEqual ( editor . getSelection ( ) ! . toString ( ) , new Selection ( 2 , 1 , 2 , 6 ) . toString ( ) , '010 ' ) ;
561+ assert . equal ( model . getLineContent ( 2 ) , 'ÖÇŞĞÜ' , '011 ' ) ;
562+ assert . deepEqual ( editor . getSelection ( ) ! . toString ( ) , new Selection ( 2 , 1 , 2 , 6 ) . toString ( ) , '012 ' ) ;
557563
558564 editor . setSelection ( new Selection ( 2 , 1 , 2 , 6 ) ) ;
559565 lowercaseAction . run ( null ! , editor ) ;
560- assert . equal ( model . getLineContent ( 2 ) , 'öçşğü' , '011' ) ;
561- assert . deepEqual ( editor . getSelection ( ) ! . toString ( ) , new Selection ( 2 , 1 , 2 , 6 ) . toString ( ) , '012' ) ;
566+ assert . equal ( model . getLineContent ( 2 ) , 'öçşğü' , '013' ) ;
567+ assert . deepEqual ( editor . getSelection ( ) ! . toString ( ) , new Selection ( 2 , 1 , 2 , 6 ) . toString ( ) , '014' ) ;
568+
569+ editor . setSelection ( new Selection ( 2 , 1 , 2 , 6 ) ) ;
570+ titlecaseAction . run ( null ! , editor ) ;
571+ assert . equal ( model . getLineContent ( 2 ) , 'Öçşğü' , '015' ) ;
572+ assert . deepEqual ( editor . getSelection ( ) ! . toString ( ) , new Selection ( 2 , 1 , 2 , 6 ) . toString ( ) , '016' ) ;
573+ }
574+ ) ;
575+
576+ withTestCodeEditor (
577+ [
578+ 'foO baR BaZ' ,
579+ 'foO\'baR\'BaZ' ,
580+ 'foO[baR]BaZ' ,
581+ 'foO`baR~BaZ' ,
582+ 'foO^baR%BaZ' ,
583+ 'foO$baR!BaZ'
584+ ] , { } , ( editor ) => {
585+ let model = editor . getModel ( ) ! ;
586+ let titlecaseAction = new TitleCaseAction ( ) ;
587+
588+ editor . setSelection ( new Selection ( 1 , 1 , 1 , 12 ) ) ;
589+ titlecaseAction . run ( null ! , editor ) ;
590+ assert . equal ( model . getLineContent ( 1 ) , 'Foo Bar Baz' ) ;
591+
592+ editor . setSelection ( new Selection ( 2 , 1 , 2 , 12 ) ) ;
593+ titlecaseAction . run ( null ! , editor ) ;
594+ assert . equal ( model . getLineContent ( 2 ) , 'Foo\'Bar\'Baz' ) ;
595+
596+ editor . setSelection ( new Selection ( 3 , 1 , 3 , 12 ) ) ;
597+ titlecaseAction . run ( null ! , editor ) ;
598+ assert . equal ( model . getLineContent ( 3 ) , 'Foo[Bar]Baz' ) ;
599+
600+ editor . setSelection ( new Selection ( 4 , 1 , 4 , 12 ) ) ;
601+ titlecaseAction . run ( null ! , editor ) ;
602+ assert . equal ( model . getLineContent ( 4 ) , 'Foo`Bar~Baz' ) ;
603+
604+ editor . setSelection ( new Selection ( 5 , 1 , 5 , 12 ) ) ;
605+ titlecaseAction . run ( null ! , editor ) ;
606+ assert . equal ( model . getLineContent ( 5 ) , 'Foo^Bar%Baz' ) ;
607+
608+ editor . setSelection ( new Selection ( 6 , 1 , 6 , 12 ) ) ;
609+ titlecaseAction . run ( null ! , editor ) ;
610+ assert . equal ( model . getLineContent ( 6 ) , 'Foo$Bar!Baz' ) ;
562611 }
563612 ) ;
564613
0 commit comments