remove extra margins on completion hovers with markdown#59786
remove extra margins on completion hovers with markdown#59786ramya-rao-a merged 7 commits intomicrosoft:masterfrom agurod42:vscode-59036
Conversation
ramya-rao-a
left a comment
There was a problem hiding this comment.
We need those margins for docs that have multiple paragraphs.
Below is one such case:
Below is the same case with the changes in this PR
Set sticky to true. Then in the local instance of VS Code, run Help -> Toggle Developer Tools -> Elements`
So, we have to
- Remove the margin top only on the first
<p>, and margin bottom on the last<p> - Add margin-bottom to the element above the
docs
|
Hi @ramya-rao-a, Loved the I made the changes you requested: |
See https://stackoverflow.com/questions/27829250/child-margin-doesnt-affect-parent-height fix styles for suggest when it has zero or two paragraphs
|
Well... It was harder than it seemed 😅 Now I think it working as expected: header + one paragraph: header + two paragraphs: header + more than two paragraphs header only no header, no markdown no header, markdown I was forced to add a class when rendering the widget in order to be able to remove the header padding when the docs section is empty. I think it shouldn't be a problem. Thanks for your help! |
| this.docs.appendChild(renderedContents.element); | ||
| } | ||
|
|
||
| toggleClass(this.el, 'empty-docs', this.docs.innerText.length === 0); |
There was a problem hiding this comment.
Is the assumption that this.docs.innerText is empty when markdown is being used?
There was a problem hiding this comment.
I am hesitant to add this class. On a cursory read of the code, it would lead one to believe that there are no "docs" associated with the suggestion item. In the suggestWidget file docs is referring to the part that appears on the right of the suggestion list.
I actually liked the change you did in your previous commit of increasing the bottom padding of .type all the time. Wouldnt that be enough (plus the margin-top/margin-bottom on first/last child)?
There was a problem hiding this comment.
There was a problem hiding this comment.
@ramya-rao-a I think the last commit solves this last issue without adding the empty-docs class. All the cases detailed in this comment #59786 (comment) are still working.
PS. Do you mind if I squash the commits in this PR?
| margin-top: 0; | ||
| } | ||
|
|
||
| .monaco-editor .suggest-widget .details > .monaco-scrollable-element > .body > .docs.markdown-docs > div > p:last-child { |
There was a problem hiding this comment.
Just curious, why do you need to use a specific rule like
.docs.markdown-docs > div > p:last-child? isn't it sufficient enough to have Just curious, why do you need to use a specific rule like .docs.markdown-docs p:last-child?
There was a problem hiding this comment.
@soleo I think there was some copy/paste problem with your comment above
| } | ||
|
|
||
| .monaco-editor .suggest-widget .details > .monaco-scrollable-element > .body > .docs.markdown-docs > div { | ||
| padding: 4px 5px; |
There was a problem hiding this comment.
Last question :)
Why are we moving the padding from .docs.markdown-docs to .docs.markdown-docs > div?
There was a problem hiding this comment.
Hehe, no problem!
I'll try to explain it:
Problem:
- We need this
padding-bottomin order to provide space between the widget's header and content:
- We also need the
.markdown-docspaddingto provide space between the content and the widget borders:
- When there is no content to show, the
.markdown-docspaddinggenerates this unwanted effect:
Solution:
When the suggestion docs has markdown content, this function is being called in order to render it's contents:
This one ends up calling the createElement in the htmlContentRenderer class, which eventually generates the html element that will be added as the .markdown-docs children:
When there is no content to show, the options.inline property becomes true and an empty span is added to the .markdown-docs. Here we shouldn't add padding.
In order to consider this scenario and avoid adding the problematic padding we can apply the padding to the .markdown-docs's immediate children instead of applying it to the .markdown-docs element itself. To do that we need to differentiate two cases:
- the children is a
divelement and we should always add padding - the children is a
spanelement and we should only add padding it thespanis not empty (I didn't found any suggestion widget withmarkdown-docsand a non-emptyspanas children but I think we should handle it, just in case).
That's why I moved the padding from .docs.markdown-docs to .docs.markdown-docs > div (and also added another rule to handle the span:non(:empty) case).
Hope I was able to explain myself in a clear way.
Kr
ramya-rao-a
left a comment
There was a problem hiding this comment.
Thanks @agurodriguez!
I hope you registered for the Microsoft Hactoberfest :)



















Fixes #59036