Skip to content

[Bug] Refactor breaks some statements into 2 lines #38204

Open
@AbdelrahmanHafez

Description

@AbdelrahmanHafez

re: #27294 (comment) microsoft/vscode#96172

Refactoring changes formatting in the sense that it removes empty lines, which is fixed by #36688 but another issue is that it breaks original code into 2 lines in some cases.

TypeScript Version: 3.9.0-dev.20200425

Search Terms: refactor, empty line, linebreak, formatting persistence.

Given the following piece of code, when I extract the condition and console.log into a function, console.log moves to a new line.

if (true) console.log('On the same line');

Expected behavior:

log();

function log () {
  if (true) console.log('On the same line');
}

Actual behavior:

log();

function log () {
  if (true)
    console.log('On the same line');
}

Related Issues: #27294 microsoft/vscode#96172

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbol

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions