Fixed bug with toggleLineComment ends in a start line

This commit is contained in:
Armando Aguirre
2020-09-25 19:00:02 -07:00
parent 73f5f02e97
commit 8cf980af8d
4 changed files with 67 additions and 2 deletions

View File

@@ -2077,6 +2077,11 @@ namespace ts {
// Push all text changes.
for (let i = firstLine; i <= lastLine; i++) {
// If the range is multiline and ends on a beginning of a line, don't comment/uncomment.
if (firstLine !== lastLine && lineStarts[i] === textRange.end) {
continue;
}
const lineTextStart = lineTextStarts.get(i.toString());
// If the line is not an empty line; otherwise no-op.

View File

@@ -0,0 +1,44 @@
// When textRange contain multiple lines and ends on a beginning of a line, don't comment/uncomment the last line.
//@Filename: file.tsx
//// [|const a = 0;
//// const b = 1;
//// |]const c = 2;
////
//// const d = <div>
//// [|<div>
//// SomeText
//// |] </div>
//// </div>;
////
//// [|//const e = 0;
//// //const f = 1;
//// |]//const g = 2;
////
//// const h = <div>
//// [|{/*<div>*/}
//// {/* SomeText*/}
//// |]{/*</div>*/}
//// </div>;
verify.toggleLineComment(
`//const a = 0;
//const b = 1;
const c = 2;
const d = <div>
{/*<div>*/}
{/* SomeText*/}
</div>
</div>;
const e = 0;
const f = 1;
//const g = 2;
const h = <div>
<div>
SomeText
{/*</div>*/}
</div>;`);

View File

@@ -13,6 +13,10 @@
//// let var9 = 3;*/|]
////
//// let var10[||] = 10;
////
//// [|let var11 = 11;
//// let var12 = 12;
//// |]let var13 = 13;
verify.toggleMultilineComment(
`let var1/* = 1;
@@ -27,4 +31,8 @@ let var7 = 1;
let var8 = 2;
let var9 = 3;
let var10/**/ = 10;`);
let var10/**/ = 10;
/*let var11 = 11;
let var12 = 12;
*/let var13 = 13;`);

View File

@@ -19,6 +19,10 @@
//// let var13 */= 3;
////
//// ////let var14 [||]= 14;
////
//// [|//let var15 = 15;
//// //let var16 = 16;
//// |]//let var17 = 17;
verify.uncommentSelection(
`let var1 = 1;
@@ -39,4 +43,8 @@ let var11 = 1;
let var12 = 2;
let var13 = 3;
//let var14 = 14;`);
//let var14 = 14;
let var15 = 15;
let var16 = 16;
//let var17 = 17;`);