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

Fix initial preview #1

Closed
wants to merge 1 commit into from

Conversation

sdirix
Copy link
Member

@sdirix sdirix commented Sep 23, 2020

What it does

Make sure preview widget content is also rendered initially for empty documents. This is important for custom preview widgets which might want to render something even if the underlying content is empty.

How to test

Create a custom preview widget handler and open it on an empty document. For example like this:

import URI from "@theia/core/lib/common/uri";
import { PreviewHandler } from "@theia/preview/lib/browser";
import { injectable } from "inversify";

@injectable()
export class MyPreviewHandler implements PreviewHandler {
  canHandle(uri: URI) {
    return 1000;
  }
  renderContent(): HTMLElement {
    const div = document.createElement("div");
    div.innerText = "my preview";
    return div;
  }
}

The preview-widget checks whether the content of the underlying text
document changed before rerendering its content. In case of empty
documents this check prevented the initial rendering of the preview.
This is now fixed by distinguishing between empty and non-existing
content.

Signed-off-by: Stefan Dirix <sdirix@eclipsesource.com>
Contributed on behalf of STMicroelectronics
@sdirix
Copy link
Member Author

sdirix commented Nov 16, 2022

Merged upstream with eclipse-theia#8729

@sdirix sdirix closed this Nov 16, 2022
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.

2 participants