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

Proper Newlines in Hover #1918

Merged
merged 30 commits into from
Jan 13, 2018
Merged

Conversation

akshita31
Copy link
Contributor

Fixes : #1057

Added Code to allow VS Code to consume the "StructuredDocumentation" object returned by omnisharp-roslyn in typelookup and append newlines appropriately. Also added an integration test for the same.

Please review : @DustinCampbell @TheRealPiotrP @rchande

Omnisharp-roslyn side : OmniSharp/omnisharp-roslyn#1038

@akshita31 akshita31 changed the title Typelookup changed Proper Newlines in Hover Dec 11, 2017
@DustinCampbell
Copy link
Member

It looks like there's something wrong with your branch in that it's picking up several changes from @rchande

@rchande
Copy link

rchande commented Dec 11, 2017

@DustinCampbell That was intentional. We needed to make a few tweaks to make integration tests more reliable.

@DustinCampbell
Copy link
Member

Got it.

documentation += structDoc[val] + newline;
}
}
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm sold on the property loop. This will cause the order of the tooltip to change if the properties are ever returned in a different order. Also, if any other element that becomes an array would get the heading "Exceptions:". Should we just check the properties we care about and construct the tooltip text in a deterministic way? E.g.

if (structDoc.SummaryText) {
    documentation += structDoc.SummaryText;
}

if (structDoc.ParamElements && structDoc.ParamElements.length > 0)) {
    documentation += "Parameters:" + newLine;
    documentation += structDoc.ParamElements.join(newLine) + newLine;
}

etc...

@DustinCampbell
Copy link
Member

@akshita31 : Could include a screenshot of the hover tooltip with your change?

@akshita31
Copy link
Contributor Author

Here is the look after the change.
final_shot

@rchande
Copy link

rchande commented Dec 11, 2017

I suspect tests are going to fail because we haven't shipped a new Omnisharp into VS Code in a while. @DustinCampbell mind if I do that this week? (Likely tomorrow)

@DustinCampbell
Copy link
Member

@rchande: I have no problem with it. Check with the OmniSharp folks though. Somebody will need to go through and update the OmniSharp changelog for all of the merged changes since 1.28 as well.

@DustinCampbell
Copy link
Member

DustinCampbell commented Dec 11, 2017

@rchande: We should make this a topic during the OmniSharp meeting tomorrow.

@DustinCampbell
Copy link
Member

@akshita31 : Do we want to include all of the tags in the hover tooltip? Visual Studio specifically doesn't do that.

image

Also, it doesn't include a "Summary" heading or the "Returns".

@DustinCampbell
Copy link
Member

If we do want to include the parameters and other items like that, I'd recommend spending some time organizing the tooltip to look a bit better organized, rather than just putting a blank line in between everything. For example:

Checks if the object is tagged with the tag.

Parameters:
    gameObject: The game object.
    tagName: Name of the tag.

Returns: Returns true if the object is tagged with tag.

Also, note that there appears to be a bug in your screenshot where there is no space between "true" and "if".

@akshita31
Copy link
Contributor Author

I tried indenting the parameters but seems that vscode doesn't display any "\t" that I added.
adding_spaces

However on adding "\t", the text color changes. I am not sure what is happening around here.

@rchande
Copy link

rchande commented Dec 12, 2017

That looks like a classification bug for @DustinCampbell to discuss.
Regarding the spacing, I think we discovered earlier that the VS Code popup turns all whitespace characters into tabs. You'll probably want to add 4 spaces (or whatever you think looks right) instead of a \t.

@DustinCampbell
Copy link
Member

@akshita31 : The "Summary" text is extra noise and a regression from previous behavior. Here's what it looks like today:

image

IMO, none of the properties on StructuredDocumentation should include a heading. Parameters, type parameters and exceptions should probably be arrays of objects with "Name" and "Documentation" properties. The text should just be the documentation string. If the host wants to add a heading during display, that's fine, but it seems strange that omnisharp-roslyn would do it. @rchande: What do you think?

@rchande
Copy link

rchande commented Dec 13, 2017

@DustinCampbell I agree. Even if we wanted to present a heading, that's something that should be up to clients, not forced on them by OmniSharp. @akshita31 Can you help work on a change to Omnisharp that so we don't add "Summary" and so forth to the section text returned from OmniSharp? Sorry we didn't catch that during your code review!

@akshita31
Copy link
Contributor Author

Yes, I'll do that.

@rchande
Copy link

rchande commented Dec 13, 2017

Also @DustinCampbell, should we wait for that change before we do the release we're planning this week?

@DustinCampbell
Copy link
Member

It wouldn't take long to make the tweak. I'd just submit the PR to omnisharp-roslyn and we'll take it. After all, we're still waiting on the three Cake PRs.

@DustinCampbell
Copy link
Member

And if we ship omnisharp-roslyn before the PR goes in, c'est la vie! I'm assuming that we'll be taking another omnisharp-roslyn before shipping omnisharp-vscode.

@rchande
Copy link

rchande commented Dec 13, 2017

@DustinCampbell By classification, I meant that it looks like adding "\t" to a string literal turns all the tokens blue (https://user-images.githubusercontent.com/12554141/33908867-9d98a40a-df3e-11e7-84fe-6302aca85a8d.png) from above.

@DustinCampbell
Copy link
Member

Oh yeah, that's weird. I wonder if VS Code's markdown grammar gets run over this.

@rchande
Copy link

rchande commented Jan 10, 2018

@rchande We need to publish omnisharp to the CDN in order to merge this.

Copy link

@rchande rchande left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of tweaks otherwise lgtm

}

if (structDoc.RemarksText) {
documentation += structDoc.RemarksText + newLine;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth extracting out a little helper method that adds the newline for you.

@@ -21,9 +21,11 @@ export default class OmniSharpHoverProvider extends AbstractSupport implements H

return serverUtils.typeLookup(this._server, req, token).then(value => {
if (value && value.Type) {
let contents = [extractSummaryText(value.Documentation), { language: 'csharp', value: value.Type }];
let structDoc = value.StructuredDocumentation;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

structDoc unused?

@rchande
Copy link

rchande commented Jan 12, 2018

@akshita31 That unused variable causing your Travis build to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants