Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOutliningSpans does not return multiline comment #22732

Closed
mjbvz opened this issue Mar 20, 2018 · 4 comments · Fixed by #36880
Closed

getOutliningSpans does not return multiline comment #22732

mjbvz opened this issue Mar 20, 2018 · 4 comments · Fixed by #36880
Assignees
Labels
Bug A bug in TypeScript Domain: Outlining Relates to multi-line regions that editors can collapse Fix Available A PR has been opened for this issue VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Mar 20, 2018

TypeScript Version: 2.8.0-dev.20180320

From microsoft/vscode#45975

Search Terms:

  • getOutliningSpans
  • Folding

Code
For the js:

/* 
comment
*/

Invoke getOutliningSpans on TS Server

Expected behavior:
Returns span that includes the multline comment

Actual behavior:
No outlining spans returned for the document

@mhegazy mhegazy added the Bug A bug in TypeScript label Mar 29, 2018
@mhegazy mhegazy added this to the TypeScript 2.9 milestone Mar 29, 2018
@mhegazy mhegazy added the Domain: Outlining Relates to multi-line regions that editors can collapse label Apr 12, 2018
@mhegazy mhegazy modified the milestones: TypeScript 2.9, TypeScript 3.0 May 3, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Jun 6, 2019

Hey @uniqueiniquity, looks like this is still in the TS 3.4 milestone along with a few other issues. Can you please review which milestone this should be in so it does not get lost

@orta
Copy link
Contributor

orta commented Feb 19, 2020

Looking through this, there's quite a lot of support for outline spans in block comments - but basically they require some kind of JavaScript in the file in order to be registered.

/// <reference path="fourslash.ts"/>

////[|/*
////    Block comment at the beginning of the file before module:
////        line one of the comment
////        line two of the comment
////        line three
////        line four
////        line five
////*/|]
////module Sayings[| {
////    [|/*
////    Comment before class:
////        line one of the comment
////        line two of the comment
////        line three
////        line four
////        line five
////    */|]
////    export class Greeter[| {
////        [|/*
////            Comment before a string identifier
////            line two of the comment
////        */|]
////        greeting: string;
////        [|/*
////            constructor
////            parameter message as a string
////        */|]
////        
////        [|/*
////            Multiple comments should be collapsed individually
////        */|]
////        constructor(message: string /* do not collapse this */)[| {
////            this.greeting = message;
////        }|]
////        [|/*
////            method of a class
////        */|]
////        greet()[| {
////            return "Hello, " + this.greeting;
////        }|]
////    }|]
////}|]
////
////[|/*
////    Block comment for interface. The ending can be on the same line as the declaration.
////*/|]interface IFoo[| {
////    [|/*
////    Multiple block comments
////    */|]
////
////    [|/*  
////    should be collapsed
////    */|]
////
////    [|/*
////    individually
////    */|]
////
////                                                                                                                              [|/*
////                                                                    this comment has trailing space before /* and after *-/ signs
////    */|]                                                                          
////
////    [|/**
////     *
////     *
////     *
////     */|]
////
////    [|/*
////    */|]
////
////    [|/*
////    */|]
////    // single line comments in the middle should not have an effect
////    [|/*
////    */|]
////
////    [|/*
////    */|]
////
////    [|/*
////    this block comment ends     
////    on the same line */|]  [|/* where the following comment starts
////        should be collapsed separately
////    */|]
////
////    getDist(): number;
////}|]
////
////var x =[|{
////  a:1,
////  b: 2,
////  [|/*
////        Over a function in an object literal
////  */|]
////  get foo()[| {
////    return 1;
////  }|]
////}|]
////
////// Over a function expression assigned to a variable
//// [|/**
////  * Return a sum
////  * @param {Number} y
////  * @param {Number} z
////  * @returns {Number} the sum of y and z
////  */|]
//// const sum2 = (y, z) =>[| {
////     return y + z;
//// }|];

verify.outliningSpansInCurrentFile(test.ranges());

It looks like the fix for the OP, and the test inside vscode this is basically to add an extra check for top-level comments which aren't attached to statements in the outliner.

@sneakyfildy
Copy link

I don't get it, is it fixed or not? Can't fold comments in vscode still.

@apaatsio
Copy link

Multiline comment folding is still inconsistent. Surely(?) the expected behavior is that all multiline comments are foldable/collapsible.

This is what I'm seeing:

vscode_multiline_comment_collapse

Source:

/*
  Isolated multiline comment: COLLAPSIBLE
*/

/*
  Multiline comment above class definition: COLLAPSIBLE
*/
class Foo {
  /*
    Multiline comment above a class member: COLLAPSIBLE
   */
  bar = 1;

  /*
    Isolated multiline comment inside a class: NOT COLLAPSIBLE
   */
}

/*
  Multiline comment above function definition: COLLAPSIBLE
*/
function foo() {
  /*
    Multiline comment inside a function: NOT COLLAPSIBLE
   */
  const bar = 1;
  return bar;
}

Visual Studio Code: 1.49.2
TypeScript: 3.9.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Outlining Relates to multi-line regions that editors can collapse Fix Available A PR has been opened for this issue VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants