respond to comments
This commit is contained in:
parent
798db1e884
commit
70bace78a0
|
@ -1117,25 +1117,6 @@ namespace ts.formatting {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean): CommentRange | undefined {
|
|
||||||
const precedingToken = findPrecedingToken(position, sourceFile);
|
|
||||||
const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end);
|
|
||||||
const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false), sourceFile);
|
|
||||||
const commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ?
|
|
||||||
trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) :
|
|
||||||
trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken;
|
|
||||||
if (commentRanges) {
|
|
||||||
for (const range of commentRanges) {
|
|
||||||
// We need to extend the range when in an unclosed multi-line comment.
|
|
||||||
if (range.pos < position && position < range.end ||
|
|
||||||
position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth())) {
|
|
||||||
return onlyMultiLine && range.kind !== SyntaxKind.MultiLineCommentTrivia ? undefined : range;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOpenTokenForList(node: Node, list: Node[]) {
|
function getOpenTokenForList(node: Node, list: Node[]) {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case SyntaxKind.Constructor:
|
case SyntaxKind.Constructor:
|
||||||
|
|
|
@ -1826,7 +1826,7 @@ namespace ts {
|
||||||
case CharacterCodes.singleQuote:
|
case CharacterCodes.singleQuote:
|
||||||
case CharacterCodes.doubleQuote:
|
case CharacterCodes.doubleQuote:
|
||||||
case CharacterCodes.backtick:
|
case CharacterCodes.backtick:
|
||||||
return !ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false);
|
return !isInComment(sourceFile, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
//// // inside regular comment /*2*/
|
//// // inside regular comment /*2*/
|
||||||
//// var c = "";
|
//// var c = "";
|
||||||
////
|
////
|
||||||
//// /* inside multi-
|
//// /*3*//* inside /*4*/multi-
|
||||||
//// line comment /*3*/
|
//// line comment /*5*/
|
||||||
//// */
|
//// */
|
||||||
//// var y =12;
|
//// var y =12;
|
||||||
//// }
|
//// }
|
||||||
|
@ -25,4 +25,12 @@ verify.not.isValidBraceCompletionAtPosition('"');
|
||||||
|
|
||||||
goTo.marker('3');
|
goTo.marker('3');
|
||||||
verify.isValidBraceCompletionAtPosition('(');
|
verify.isValidBraceCompletionAtPosition('(');
|
||||||
|
verify.isValidBraceCompletionAtPosition('"');
|
||||||
|
|
||||||
|
goTo.marker('4');
|
||||||
|
verify.isValidBraceCompletionAtPosition('(');
|
||||||
|
verify.not.isValidBraceCompletionAtPosition('"');
|
||||||
|
|
||||||
|
goTo.marker('5');
|
||||||
|
verify.isValidBraceCompletionAtPosition('(');
|
||||||
verify.not.isValidBraceCompletionAtPosition('"');
|
verify.not.isValidBraceCompletionAtPosition('"');
|
Loading…
Reference in a new issue