Microsoft/TypeScript

extract function including traling comment that is not selected

Open

#54.126 geöffnet am 4. Mai 2023

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
Domain: LS: RefactoringsExperience EnhancementHelp WantedSuggestion

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

Bug Report

extract function including traling comment that is not selected

🔎 Search Terms

🕗 Version & Regression Information

  • This is a bug in 4.3.2-latest version When I use 'extract to method in class C' in following code, the selected region does not contain comment '/end/', but when I excecute 'extract to method in class C', the extractd method contains comment '/end/'. Is this a bug?I think it would better comment not selected appear in newMethod.

⏯ Playground Link

Playground link with relevant code

💻 Code

class C{
  a() {
    let z =1;
    /*start*/let a1= {x:1};
    let y =10;
    z=42
    return a1.x+ 10 /*end*/
  }
}

🙁 Actual behavior

class C{
  a() {
    let z = 1;
    /*start*/
    let __return;
    ({ __return, z } = this.newMethod(z));
    return __return; /*end*
  }
  private newMethod(z: number) {
    let a1 = { x: 1 };
    let y = 10;
    z = 42;
    return { __return: a1.x + 10 /*end*/
    , z };
  }
}

🙂 Expected behavior

class C{
  a() {
    let z = 1;
    /*start*/
    let __return;
    ({ __return, z } = this.newMethod(z));
    return __return; /*end*/
  }

  private newMethod(z: number) {
    let a1 = { x: 1 };
    let y = 10;
    z = 42;
    return { __return: a1.x + 10 , z };
  }
}

Contributor Guide