Skip to content

Visual Studio - Format on Enter no longer removes extra whitespace #28781

Closed

Description

TypeScript Version:
typescript@3.3.0-dev.20181130

Search Terms:
formatting whitespace

Expected behavior:
Format on Enter previously removed extra whitespace inserted after the indentation on the empty line below var bar;. Caret represents the termination of whitespace on the previous line.

function foo()
{
    var bar;
    
    ^
}

Actual behavior:

Format on Enter no longer removes extra whitespace.

function foo()
{
    var bar;
        
        ^
}

Similar behavior is observed for non-empty lines.
Expected:

var foo;
        ^

Actual:

var foo;     
            ^

Related Issues:
Introduced by #27978

Activity

  1. minestarks commented on Dec 3, 2018

    @minestarks
    Contributor

    Nathan Shively-Sanders (@sandersn) This is blocking our tests and I believe it exists in 3.2 which will ship with VS. My understanding is it causes a visible formatting issue in VS. Would you prioritize it accordingly?

  2. sandersn commented on Dec 4, 2018

    @sandersn
    Member

    Here's a fourslash repro:

    /// <reference path="fourslash.ts" />
    ////function foo()
    ////{
    ////    var bar;
    ////    /*1*/
    ////}
    goTo.marker('1')
    edit.insertLine("");
    verify.currentFileContentIs(`function foo()
    {
        var bar;
    
    
    }`);

    The two whitespace-only lines should both have 0 spaces. After #27978 merged, the first one still has 4 spaces.

  3. sandersn commented on Dec 4, 2018

    @sandersn
    Member

    Selectively reverting #27978 shows that the regression was introduced by the change in trimTrailingWhitespacesForRemainingRange.

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: FormatterThe issue relates to the built-in formatterDomain: LS: TSServerIssues related to the TSServerVisual StudioIntegration with Visual Studio

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions