open view in current window not in new one
This commit is contained in:
@ -72,19 +72,24 @@ class OpenMarkdownPreviewCommand(sublime_plugin.TextCommand):
|
||||
|
||||
syntax_file = original_view.settings().get("syntax")
|
||||
|
||||
if file_name:
|
||||
original_view.close()
|
||||
else:
|
||||
# the file isn't saved, we need to restore the content manually
|
||||
# don't close the original view; keep it in your main window:
|
||||
# if file_name:
|
||||
# original_view.close()
|
||||
# else:
|
||||
# # the file isn't saved, we need to restore the content manually
|
||||
# total_region = sublime.Region(0, original_view.size())
|
||||
# content = original_view.substr(total_region)
|
||||
# original_view.erase(edit, total_region)
|
||||
# original_view.close()
|
||||
# # FIXME: save the document to a temporary file, so that if we crash,
|
||||
# # the user doesn't lose what he wrote
|
||||
if not file_name:
|
||||
# If the file isn't saved, we still need the content for the new view
|
||||
total_region = sublime.Region(0, original_view.size())
|
||||
content = original_view.substr(total_region)
|
||||
original_view.erase(edit, total_region)
|
||||
original_view.close()
|
||||
# FIXME: save the document to a temporary file, so that if we crash,
|
||||
# the user doesn't lose what he wrote
|
||||
|
||||
sublime.run_command("new_window")
|
||||
preview_window = sublime.active_window()
|
||||
# instead of making a new window, grab your existing one:
|
||||
preview_window = original_view.window()
|
||||
|
||||
preview_window.run_command(
|
||||
"set_layout",
|
||||
@ -172,7 +177,8 @@ class MarkdownLivePreviewListener(sublime_plugin.EventListener):
|
||||
if markdown_view.id() in self.phantom_sets:
|
||||
del self.phantom_sets[markdown_view.id()]
|
||||
|
||||
self.preview_window.run_command("close_window")
|
||||
# don’t close the entire window—just let the user close the preview tab:
|
||||
# self.preview_window.run_command("close_window")
|
||||
|
||||
# find the window with the right id
|
||||
original_window = next(
|
||||
|
||||
Reference in New Issue
Block a user