test if onlyMultiLine
flag changes answer
This commit is contained in:
parent
6029b5cce8
commit
760ef44c36
6 changed files with 32 additions and 31 deletions
|
@ -2508,16 +2508,19 @@ namespace FourSlash {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public verifySpanOfEnclosingComment(negative: boolean, onlyMultiLine: boolean) {
|
public verifySpanOfEnclosingComment(negative: boolean, onlyMultiLineDiverges?: boolean) {
|
||||||
const expected = !negative;
|
const expected = !negative;
|
||||||
const position = this.currentCaretPosition;
|
const position = this.currentCaretPosition;
|
||||||
const fileName = this.activeFile.fileName;
|
const fileName = this.activeFile.fileName;
|
||||||
const actual = !!this.languageService.getSpanOfEnclosingComment(fileName, position, /*onlyMultiLine*/ onlyMultiLine);
|
const actual = !!this.languageService.getSpanOfEnclosingComment(fileName, position, /*onlyMultiLine*/ false);
|
||||||
if (expected !== actual) {
|
const actualOnlyMultiLine = !!this.languageService.getSpanOfEnclosingComment(fileName, position, /*onlyMultiLine*/ true);
|
||||||
|
if (expected !== actual || onlyMultiLineDiverges === (actual === actualOnlyMultiLine)) {
|
||||||
this.raiseError(`verifySpanOfEnclosingComment failed:
|
this.raiseError(`verifySpanOfEnclosingComment failed:
|
||||||
position: '${position}'
|
position: '${position}'
|
||||||
fileName: '${fileName}'
|
fileName: '${fileName}'
|
||||||
onlyMultiLine: '${onlyMultiLine}'
|
onlyMultiLineDiverges: '${onlyMultiLineDiverges}'
|
||||||
|
actual: '${actual}'
|
||||||
|
actualOnlyMultiLine: '${actualOnlyMultiLine}'
|
||||||
expected: '${expected}'.`);
|
expected: '${expected}'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3662,8 +3665,8 @@ namespace FourSlashInterface {
|
||||||
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
|
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public isInCommentAtPosition(onlyMultiLine: boolean) {
|
public isInCommentAtPosition(onlyMultiLineDiverges?: boolean) {
|
||||||
this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLine);
|
this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLineDiverges);
|
||||||
}
|
}
|
||||||
|
|
||||||
public codeFixAvailable() {
|
public codeFixAvailable() {
|
||||||
|
|
|
@ -153,7 +153,7 @@ declare namespace FourSlashInterface {
|
||||||
typeDefinitionCountIs(expectedCount: number): void;
|
typeDefinitionCountIs(expectedCount: number): void;
|
||||||
implementationListIsEmpty(): void;
|
implementationListIsEmpty(): void;
|
||||||
isValidBraceCompletionAtPosition(openingBrace?: string): void;
|
isValidBraceCompletionAtPosition(openingBrace?: string): void;
|
||||||
isInCommentAtPosition(onlyMultiLine: boolean): void;
|
isInCommentAtPosition(onlyMultiLineDiverges?: boolean): void;
|
||||||
codeFixAvailable(): void;
|
codeFixAvailable(): void;
|
||||||
applicableRefactorAvailableAtMarker(markerName: string): void;
|
applicableRefactorAvailableAtMarker(markerName: string): void;
|
||||||
codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void;
|
codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void;
|
||||||
|
|
|
@ -11,37 +11,36 @@
|
||||||
const firstCommentStart = 0;
|
const firstCommentStart = 0;
|
||||||
const firstCommentEnd = 7;
|
const firstCommentEnd = 7;
|
||||||
goTo.position(firstCommentStart);
|
goTo.position(firstCommentStart);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
|
|
||||||
goTo.position(firstCommentStart + 1);
|
goTo.position(firstCommentStart + 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
goTo.position(firstCommentEnd - 1);
|
goTo.position(firstCommentEnd - 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
|
|
||||||
goTo.position(firstCommentEnd);
|
goTo.position(firstCommentEnd);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
|
|
||||||
const multilineJsDocStart = firstCommentEnd + 1;
|
const multilineJsDocStart = firstCommentEnd + 1;
|
||||||
const multilineJsDocEnd = multilineJsDocStart + 49;
|
const multilineJsDocEnd = multilineJsDocStart + 49;
|
||||||
|
|
||||||
goTo.position(multilineJsDocStart);
|
goTo.position(multilineJsDocStart);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
goTo.position(multilineJsDocStart + 1);
|
goTo.position(multilineJsDocStart + 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
goTo.position(multilineJsDocEnd - 1);
|
goTo.position(multilineJsDocEnd - 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
goTo.position(multilineJsDocEnd);
|
goTo.position(multilineJsDocEnd);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
|
|
||||||
const singleLineCommentStart = multilineJsDocEnd + 1;
|
const singleLineCommentStart = multilineJsDocEnd + 1;
|
||||||
|
|
||||||
goTo.position(singleLineCommentStart + 1);
|
goTo.position(singleLineCommentStart + 1);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition(/*onlyMultiLineDiverges*/ true);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ false);
|
|
||||||
|
|
||||||
const postNodeCommentStart = singleLineCommentStart + 16;
|
const postNodeCommentStart = singleLineCommentStart + 16;
|
||||||
|
|
||||||
goTo.position(postNodeCommentStart);
|
goTo.position(postNodeCommentStart);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
goTo.position(postNodeCommentStart + 1);
|
goTo.position(postNodeCommentStart + 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
|
|
|
@ -23,5 +23,5 @@
|
||||||
|
|
||||||
for (let i = 0; i < 10; ++i) {
|
for (let i = 0; i < 10; ++i) {
|
||||||
goTo.marker(i.toString());
|
goTo.marker(i.toString());
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false);
|
verify.not.isInCommentAtPosition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,5 @@
|
||||||
|
|
||||||
for (let i = 0; i < 9; ++i) {
|
for (let i = 0; i < 9; ++i) {
|
||||||
goTo.marker(i.toString());
|
goTo.marker(i.toString());
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false);
|
verify.not.isInCommentAtPosition();
|
||||||
}
|
}
|
|
@ -9,30 +9,29 @@
|
||||||
const firstCommentStart = 0;
|
const firstCommentStart = 0;
|
||||||
const firstCommentEnd = 7;
|
const firstCommentEnd = 7;
|
||||||
goTo.position(firstCommentStart);
|
goTo.position(firstCommentStart);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
|
|
||||||
goTo.position(firstCommentStart + 1);
|
goTo.position(firstCommentStart + 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
goTo.position(firstCommentEnd - 1);
|
goTo.position(firstCommentEnd - 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
|
|
||||||
goTo.position(firstCommentEnd);
|
goTo.position(firstCommentEnd);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
|
|
||||||
const multilineJsDocStart = firstCommentEnd + 1;
|
const multilineJsDocStart = firstCommentEnd + 1;
|
||||||
const multilineJsDocEnd = multilineJsDocStart + 49;
|
const multilineJsDocEnd = multilineJsDocStart + 49;
|
||||||
|
|
||||||
goTo.position(multilineJsDocStart);
|
goTo.position(multilineJsDocStart);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
goTo.position(multilineJsDocStart + 1);
|
goTo.position(multilineJsDocStart + 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
goTo.position(multilineJsDocEnd - 1);
|
goTo.position(multilineJsDocEnd - 1);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition();
|
||||||
goTo.position(multilineJsDocEnd);
|
goTo.position(multilineJsDocEnd);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.not.isInCommentAtPosition();
|
||||||
|
|
||||||
const singleLineCommentStart = multilineJsDocEnd + 1;
|
const singleLineCommentStart = multilineJsDocEnd + 1;
|
||||||
|
|
||||||
goTo.position(singleLineCommentStart + 1);
|
goTo.position(singleLineCommentStart + 1);
|
||||||
verify.not.isInCommentAtPosition(/*onlyMultiLine*/ true);
|
verify.isInCommentAtPosition(/*onlyMultiLineDiverges*/ true);
|
||||||
verify.isInCommentAtPosition(/*onlyMultiLine*/ false);
|
|
Loading…
Reference in a new issue