Do not set breakpoints on the blank line or comment only line

This commit is contained in:
Sheetal Nandi
2014-10-20 23:01:06 -07:00
parent 0cb2e983aa
commit 4a8a8920a2
7 changed files with 67 additions and 23 deletions

View File

@@ -10,7 +10,7 @@ module ts.BreakpointResolver {
export function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number) {
// Cannot set breakpoint in dts file
if (sourceFile.flags & NodeFlags.DeclarationFile) {
return;
return undefined;
}
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
@@ -22,11 +22,16 @@ module ts.BreakpointResolver {
// token at position will return var keyword on second line as the token but we would like to use
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
// Its a blank line
if (!tokenAtLocation || sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
return undefined;
}
}
// Cannot set breakpoint in ambient declarations
if (isInAmbientContext(tokenAtLocation)) {
return;
return undefined;
}
// Get the span in the node based on its syntax