From fd633e0bc065251f93466b1ea093f48c23bb35d6 Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Thu, 5 Jan 2017 09:18:09 +1100 Subject: [PATCH] focus the md_view back --- MLPApi.py | 7 ++++--- MarkdownLivePreview.py | 1 + sample.md | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/MLPApi.py b/MLPApi.py index 958dab2..3d3719e 100644 --- a/MLPApi.py +++ b/MLPApi.py @@ -42,9 +42,10 @@ def create_preview(md_view): preview.set_name(get_preview_name(md_view)) preview.set_scratch(True) md_view_settings.set(PREVIEW_ID, preview.id()) - window.run_command('new_pane') # move to new group - return preview - + def move_and_focus_md_view(): + window.run_command('new_pane') + sublime.set_timeout_async(lambda: window.focus_view(md_view), 50) + sublime.set_timeout_async(move_and_focus_md_view, 250) return preview diff --git a/MarkdownLivePreview.py b/MarkdownLivePreview.py index 15ab19d..aed3f96 100644 --- a/MarkdownLivePreview.py +++ b/MarkdownLivePreview.py @@ -18,6 +18,7 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener): id = vsettings.get(PREVIEW_ID) if id is None or get_view_from_id(window, id) is None: preview = create_preview(view) + return def on_activated(self, view): # if view is md_view and has no preview diff --git a/sample.md b/sample.md index 91b2cf3..8a2eeac 100644 --- a/sample.md +++ b/sample.md @@ -1,7 +1,8 @@ -# DuckDuckGo - The Search engine you'll fall in love with +# DuckDuckGo - The Search engine you'll fall in love with + +This is a test ![image](http://afterishtar.pl/images/100x100.gif) - -this is a test -hello world... \ No newline at end of file +hello world +