File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,11 @@ namespace ts {
99 Instantiated = 1 ,
1010 ConstEnumOnly = 2
1111 }
12+
13+ "/**"
1214
15+ /* /** */
16+ // /** getDocCommentScaffoldingAtPosition -- TS side! */
1317 export function getModuleInstanceState ( node : Node ) : ModuleInstanceState {
1418 // A module is uninstantiated if it contains only
1519 // 1. interface declarations, type alias declarations
Original file line number Diff line number Diff line change @@ -6756,19 +6756,21 @@ namespace ts {
67566756 * be performed.
67576757 */
67586758 function getDocCommentScaffoldingAtPosition ( fileName : string , position : number ) : string {
6759- const nullResult = "/** */" ;
6759+ const nullResult = "/**" ;
6760+ const emptyCompletion = "/** */" ;
67606761 let start = new Date ( ) . getTime ( ) ;
67616762 let sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
67626763 log ( "getDocCommentScaffoldingAtPosition: getCurrentSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
67636764
67646765 // Check if in comment context
6765- var nodeAtPos = getTokenAtPosition ( sourceFile , position ) ;
6766-
6767- return "/** token is : daniel cant copy/paste " + tokenToString ( nodeAtPos . kind ) + " */" ;
6766+ if ( isInString ( sourceFile , position ) || isInComment ( sourceFile , position ) ) { return nullResult ; }
67686767
67696768 // Get the next non-comment token
6769+ var nodeAtPos = getTokenAtPosition ( sourceFile , position ) ;
6770+ var containingFunction = getAncestor ( nodeAtPos , SyntaxKind . FunctionDeclaration ) ;
67706771
67716772 // check if token is a function keyword
6773+ if ( ! containingFunction ) { return emptyCompletion ; }
67726774
67736775 // Get the parsed object corresponding to the token
67746776
Original file line number Diff line number Diff line change @@ -438,7 +438,18 @@ namespace ts {
438438
439439 // Then we want to make sure that it wasn't in a "///<" directive comment
440440 // We don't want to unintentionally update a file name.
441- return forEach ( commentRanges , c => c . pos < position && position < c . end && extraCheck ( c ) ) ;
441+ return forEach ( commentRanges , c => c . pos < position &&
442+ // The end marker of a single-line comment does not include the newline character.
443+ // In the following case, we are inside a comment (^ denotes the cursor position):
444+ //
445+ // // asdf ^\n
446+ //
447+ // But for multi-line comments, we don't want to be inside the comment in the following case:
448+ // /* asdf */^
449+ //
450+ // Internally, we represent the end of the comment at the newline and closing '/', respectively.
451+ ( c . kind == SyntaxKind . SingleLineCommentTrivia ? position <= c . end : position < c . end ) &&
452+ extraCheck ( c ) ) ;
442453 }
443454
444455 return false ;
You can’t perform that action at this time.
0 commit comments