Skip to content

Commit 70bace7

Browse files
committed
respond to comments
1 parent 798db1e commit 70bace7

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

src/services/formatting/formatting.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,25 +1117,6 @@ namespace ts.formatting {
11171117
}
11181118
}
11191119

1120-
export function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean): CommentRange | undefined {
1121-
const precedingToken = findPrecedingToken(position, sourceFile);
1122-
const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end);
1123-
const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), sourceFile);
1124-
const commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ?
1125-
trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) :
1126-
trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken;
1127-
if (commentRanges) {
1128-
for (const range of commentRanges) {
1129-
// We need to extend the range when in an unclosed multi-line comment.
1130-
if (range.pos < position && position < range.end ||
1131-
position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth())) {
1132-
return onlyMultiLine && range.kind !== SyntaxKind.MultiLineCommentTrivia ? undefined : range;
1133-
}
1134-
}
1135-
}
1136-
return undefined;
1137-
}
1138-
11391120
function getOpenTokenForList(node: Node, list: Node[]) {
11401121
switch (node.kind) {
11411122
case SyntaxKind.Constructor:

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ namespace ts {
18261826
case CharacterCodes.singleQuote:
18271827
case CharacterCodes.doubleQuote:
18281828
case CharacterCodes.backtick:
1829-
return !ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false);
1829+
return !isInComment(sourceFile, position);
18301830
}
18311831

18321832
return true;

tests/cases/fourslash/commentBraceCompletionPosition.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//// // inside regular comment /*2*/
88
//// var c = "";
99
////
10-
//// /* inside multi-
11-
//// line comment /*3*/
10+
//// /*3*//* inside /*4*/multi-
11+
//// line comment /*5*/
1212
//// */
1313
//// var y =12;
1414
//// }
@@ -25,4 +25,12 @@ verify.not.isValidBraceCompletionAtPosition('"');
2525

2626
goTo.marker('3');
2727
verify.isValidBraceCompletionAtPosition('(');
28+
verify.isValidBraceCompletionAtPosition('"');
29+
30+
goTo.marker('4');
31+
verify.isValidBraceCompletionAtPosition('(');
32+
verify.not.isValidBraceCompletionAtPosition('"');
33+
34+
goTo.marker('5');
35+
verify.isValidBraceCompletionAtPosition('(');
2836
verify.not.isValidBraceCompletionAtPosition('"');

0 commit comments

Comments
 (0)