-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
Consider the following code:
// a
var q = /*b*/ //c
/*d*/ 1 /*e*/ //f
/*g*/ + /*h*/ //i
/*j*/ 2 /*k*/ //l
/*m*/; /*n*/ //oSuppose we extract the range from 1 to 2 (inclusive) into a separate function. We would like comments e-j to move to the new function and the others to remain where they are:
// a
var q = /*b*/ //c
/*d*/ newFunction() /*k*/ //l
/*m*/; /*n*/ //o
function newFunction() {
return 1 /*e*/ //f
/*g*/ + /*h*/ //i
/*j*/ 2;
}Presently, there doesn't seem to be a way to express this. We can cause the leading and trailing trivia to remain at the call site by replacing a range ({pos: expr.getStart(), end: expr.end}), rather than a node (expr), but there doesn't seem to be a way to strip the leading and trailing trivia in the body of the extracted function.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolFixedA PR has been merged for this issueA PR has been merged for this issue