Skip to content

Fix for #2128 (Outlining cuts off closing } )#26551

Merged
jinujoseph merged 1 commit intodotnet:masterfrom
josetr:master
Jun 11, 2018
Merged

Fix for #2128 (Outlining cuts off closing } )#26551
jinujoseph merged 1 commit intodotnet:masterfrom
josetr:master

Conversation

@josetr
Copy link
Copy Markdown
Contributor

@josetr josetr commented May 2, 2018

For example, view.LineHeight may be 12 when SizeToFit() is called, but when the first LayoutChanged event is received, it may have changed to 11, 13, etc. This bug is not obvious because it only happens with the right combination of Font Size or Editor Zoom %.

There is another pull request addressing this issue (#20825), but it breaks for me if the zoom is set to some weird value like 99%.

  1. Removed the comment that says 'Fortunately, a layout is going to occur because we set 'Height' above.' because it's no longer true in VS2017 (perhaps it was for VS2015).
  2. Removed the other comments because I think the code is self explanatory now.
  3. The method IsNormal is now inside SizeToFit because It only works in this context.

Since we are talking about the outlining tooltip, I've noticed that it's trimmed based on the amount of characters (1000 max), is this really what we want? shouldn't it be trimmed based on the amount of lines instead?

@josetr josetr requested a review from a team as a code owner May 2, 2018 00:08
@etbyrd etbyrd added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label May 2, 2018
@jcouv jcouv added the Area-IDE label May 3, 2018
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@jinujoseph Can this community PR be given a buddy? Preferably someone familiar with WPF. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curlies required in all IDE code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you add a comment why this is necessary? For example, i can see: view.VisualElement.Height = view.LineHeight * view.TextBuffer.CurrentSnapshot.LineCount; a few lines above this. So why would would this have any effect? Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because they are executed at different points in time and may not give the same result since they rely on view.LineHeight which is mutable. They may give the same value sometimes, but by coincidence, and that's why this bug is not obvious and hasn't been fixed earlier.

I've removed the first view.VisualElement.Height = ... with the last commit since it's not necessary in VS2017.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do you only do this if 'currentHeight' is 'normal'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mistake, fixed in the last commit.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

If there is a view.LayoutChanged += firstLayout; and the goal (based on the name) is to watch for the firstLayout change, why isn't there a respective view.LayoutChanged -= firstLayout;? or if the intent is to watch for layout changes forever, then I believe the function should be renamed.

It's probable because this codepath was only expected to be used by wpf views that we only expected a single layout to occur for. It's likely ok to add the -= in it to detach just so we don't do anything past the first layout.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

I don't know if the comment is wrong or partially right,

Can you do some experimentation to find out?

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Since we are talking about the outlining tooltip, I've noticed that it's trimmed based on the amount of characters (1000 max), is this really what we want? shouldn't it be trimmed based on the amount of lines instead?

Sure. That seems somewhat reasonable. However, i would do that in another PR.

@dnfclas
Copy link
Copy Markdown

dnfclas commented May 18, 2018

CLA assistant check
All CLA requirements met.

@jasonmalinowski
Copy link
Copy Markdown
Member

This doesn't seem more terrifying than any other code that ever touches this. Anybody else from @dotnet/roslyn-ide want a crack?

@jinujoseph We'll need your approval; looks fine to me.

@jasonmalinowski
Copy link
Copy Markdown
Member

@dotnet-bot retest this please.

@jinujoseph
Copy link
Copy Markdown
Contributor

@sharwell for second review

This bug ocurred because the height was calculated too early. We can't rely on `view.LineHeight` too early because Visual Studio may still change it depending on your `Font Settings` or `Editor Zoom %`.

I've also done some refactoring & removed the comments because they are no longer needed.
@josetr
Copy link
Copy Markdown
Contributor Author

josetr commented Jun 7, 2018

@jasonmalinowski thanks for approving the changes altho I think you may need to do it again because I've merged all the commits into 1 and cleaned up the description. This is something I wanted to do a long time ago but forgot, sorry for that.

@jasonmalinowski
Copy link
Copy Markdown
Member

@josetr Not a problem!

@jasonmalinowski jasonmalinowski requested review from a team and sharwell June 8, 2018 20:21
@jasonmalinowski
Copy link
Copy Markdown
Member

@jinujoseph This one is ready for delegated M2 approval.

@jinujoseph
Copy link
Copy Markdown
Contributor

Approved to merge for 15.8.Preview4

@jinujoseph jinujoseph merged commit 7035d53 into dotnet:master Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved to merge Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants