Skip to content

Commit 3cc0aeb

Browse files
committed
PR comments
I plan to fix the missing comment issue when I add the convert-jsdoc-types-to-typescript-types refactoring. Or at least work around it.
1 parent 410f846 commit 3cc0aeb

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/services/textChanges.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ namespace ts.textChanges {
152152
return position === Position.Start ? start : fullStart;
153153
}
154154
// get start position of the line following the line that contains fullstart position
155-
let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + (fullStart > 0 ? 1 : 0), sourceFile);
155+
// (but only if the fullstart isn't the very beginning of the file)
156+
const nextLineStart = fullStart > 0 ? 1 : 0;
157+
let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + nextLineStart, sourceFile);
156158
// skip whitespaces/newlines
157159
adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition);
158160
return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile);

tests/cases/fourslash/extract-method-uniqueName.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
////// newFunction
44
/////*start*/1 + 1/*end*/;
55

6+
// NOTE: '// newFunction' should be included, but due to incorrect handling of trivia,
7+
// it's omitted right now.
68
goTo.select('start', 'end')
79
edit.applyRefactor({
810
refactorName: "Extract Method",

tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//// }
1313

1414
verify.applicableRefactorAvailableAtMarker('1');
15+
// NOTE: '// Comment' should be included, but due to incorrect handling of trivia,
16+
// it's omitted right now.
1517
verify.fileAfterApplyingRefactorAtMarker('1',
1618
`class fn {
1719
constructor() {

0 commit comments

Comments
 (0)