diff --git a/MLPApi.py b/MLPApi.py index fb92a3d..3ccb93f 100644 --- a/MLPApi.py +++ b/MLPApi.py @@ -132,6 +132,7 @@ def show_html(md_view, preview): # set viewport position + return # 0 < y < 1 y = md_view.text_to_layout(md_view.sel()[0].begin())[1] / md_view.layout_extent()[1] vector = [0, y * preview.layout_extent()[1]] diff --git a/MarkdownLivePreview.py b/MarkdownLivePreview.py index 0515d80..0ae50d4 100644 --- a/MarkdownLivePreview.py +++ b/MarkdownLivePreview.py @@ -16,8 +16,13 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener): vsettings = view.settings() if vsettings.get(PREVIEW_ENABLED): id = vsettings.get(PREVIEW_ID) - if id is None or get_view_from_id(window, id) is None: + preview = get_view_from_id(window, id) + if id is None or preview is None: preview = create_preview(view) + sublime.set_timeout(lambda: show_html(view, preview), 1000) + else: + show_html(view, preview) + return def on_activated(self, view): @@ -27,8 +32,12 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener): vsettings = view.settings() if vsettings.get(PREVIEW_ENABLED): id = vsettings.get(PREVIEW_ID) - if id is None or get_view_from_id(window, id) is None: + preview = get_view_from_id(window, id) + if id is None or preview is None: preview = create_preview(view) + sublime.set_timeout(lambda: show_html(view, preview), 1000) + else: + show_html(view, preview) return # if view is preview diff --git a/sample.md b/sample.md index f36bb22..a4019fc 100644 --- a/sample.md +++ b/sample.md @@ -1,7 +1,7 @@ # DuckDuckGo - The Search engine you'll fall in love with -This is a test +This is a test, and this is pretty cool! ![image](http://afterishtar.pl/images/100x100.gif) -hello world +Hope you'll enjoy using MarkdownLivePreview!