use timeout (1s) only when needed
The timeout are needed, at least on my computer, because ST crashes otherwise
This commit is contained in:
@ -132,6 +132,7 @@ def show_html(md_view, preview):
|
|||||||
|
|
||||||
# set viewport position
|
# set viewport position
|
||||||
|
|
||||||
|
return
|
||||||
# 0 < y < 1
|
# 0 < y < 1
|
||||||
y = md_view.text_to_layout(md_view.sel()[0].begin())[1] / md_view.layout_extent()[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]]
|
vector = [0, y * preview.layout_extent()[1]]
|
||||||
|
|||||||
@ -16,8 +16,13 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
|||||||
vsettings = view.settings()
|
vsettings = view.settings()
|
||||||
if vsettings.get(PREVIEW_ENABLED):
|
if vsettings.get(PREVIEW_ENABLED):
|
||||||
id = vsettings.get(PREVIEW_ID)
|
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)
|
preview = create_preview(view)
|
||||||
|
sublime.set_timeout(lambda: show_html(view, preview), 1000)
|
||||||
|
else:
|
||||||
|
show_html(view, preview)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_activated(self, view):
|
def on_activated(self, view):
|
||||||
@ -27,8 +32,12 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
|||||||
vsettings = view.settings()
|
vsettings = view.settings()
|
||||||
if vsettings.get(PREVIEW_ENABLED):
|
if vsettings.get(PREVIEW_ENABLED):
|
||||||
id = vsettings.get(PREVIEW_ID)
|
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)
|
preview = create_preview(view)
|
||||||
|
sublime.set_timeout(lambda: show_html(view, preview), 1000)
|
||||||
|
else:
|
||||||
|
show_html(view, preview)
|
||||||
return
|
return
|
||||||
|
|
||||||
# if view is preview
|
# if view is preview
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# DuckDuckGo - The Search engine you'll fall in love with
|
# DuckDuckGo - The Search engine you'll fall in love with
|
||||||
|
|
||||||
This is a test
|
This is a test, and this is pretty cool!
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
hello world
|
Hope you'll enjoy using MarkdownLivePreview!
|
||||||
|
|||||||
Reference in New Issue
Block a user