Check if inside the declaration

This commit is contained in:
Arthur Ozga 2015-07-23 14:03:52 -07:00
parent acb9401345
commit 24b29f1fb7
4 changed files with 5 additions and 4 deletions

View File

@ -1945,7 +1945,7 @@ module FourSlash {
let actual = this.languageService.getDocCommentScaffoldingAtPosition(this.activeFile.fileName, this.currentCaretPosition);
if (actual.newText !== expected.newText) {
this.raiseError('verifyDocCommentScaffolding failed - expected insertion:\n' + expected.newText + 'actual insertion:\n' + actual.newText);
this.raiseError('verifyDocCommentScaffolding failed - expected insertion:\n' + expected.newText + '\nactual insertion:\n' + actual.newText);
}
if (actual.cursorOffset !== expected.cursorOffset) {

View File

@ -6778,7 +6778,7 @@ namespace ts {
let nodeAtPos = getTokenAtPosition(sourceFile, position);
let containingFunction = <FunctionDeclaration>getAncestor(nodeAtPos, SyntaxKind.FunctionDeclaration);
if (hasDocComment(sourceFile, position) || !containingFunction) {
if (hasDocComment(sourceFile, position) || !containingFunction || containingFunction.getStart() < position) {
return emptyCompletion;
}

View File

@ -432,7 +432,7 @@ namespace ts {
extraCheck: (c: CommentRange) => boolean): boolean {
let token = getTokenAtPosition(sourceFile, position);
if (token && position < token.getStart()) {
if (token && position <= token.getStart()) {
let commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
return forEach(commentRanges, c => c.pos < position &&
@ -442,6 +442,7 @@ namespace ts {
// // asdf ^\n
//
// But for multi-line comments, we don't want to be inside the comment in the following case:
//
// /* asdf */^
//
// Internally, we represent the end of the comment at the newline and closing '/', respectively.

View File

@ -379,7 +379,7 @@ module FourSlashInterface {
}
// Will fix in fourslash-referencing
public DocCommentScaffolding(position: number, expectedText: string, expectedOffset: number) {
public DocCommentScaffolding(expectedText: string, expectedOffset: number) {
FourSlash.currentTestState.verifyDocCommentScaffolding({ newText: expectedText, cursorOffset: expectedOffset });
}