mirror of
https://github.com/hexedtech/codemp-sublime.git
synced 2025-03-26 03:31:32 +01:00
fix: now when joining a buffer the text is correctly loaded and the syntax is assigned
This commit is contained in:
parent
8e6e9e07a1
commit
db033e7882
2 changed files with 14 additions and 19 deletions
plugin
|
@ -18,7 +18,7 @@ class CodempJoinBufferCommand(sublime_plugin.WindowCommand):
|
|||
return len(workspaces.lookup(self.window)) > 0
|
||||
|
||||
def input_description(self) -> str:
|
||||
return "Attach: "
|
||||
return "Join Buffer: "
|
||||
|
||||
def input(self, args):
|
||||
if "workspace_id" not in args:
|
||||
|
@ -46,8 +46,8 @@ class CodempJoinBufferCommand(sublime_plugin.WindowCommand):
|
|||
|
||||
try: # if it exists already, focus and listen
|
||||
buff = buffers.lookupId(buffer_id)
|
||||
safe_listener_detach(TEXT_LISTENER)
|
||||
safe_listener_attach(TEXT_LISTENER, buff.view.buffer())
|
||||
# safe_listener_detach(TEXT_LISTENER)
|
||||
# safe_listener_attach(TEXT_LISTENER, buff.view.buffer())
|
||||
self.window.focus_view(buff.view)
|
||||
return
|
||||
except KeyError:
|
||||
|
@ -66,17 +66,10 @@ class CodempJoinBufferCommand(sublime_plugin.WindowCommand):
|
|||
sublime.error_message(f"Could not attach to buffer '{buffer_id}'")
|
||||
return
|
||||
|
||||
safe_listener_detach(TEXT_LISTENER)
|
||||
content_promise = buff_ctl.content()
|
||||
vbuff = buffers.register(buff_ctl, vws)
|
||||
|
||||
content = content_promise.wait()
|
||||
populate_view(vbuff.view, content)
|
||||
if self.window.active_view() == vbuff.view:
|
||||
# if view is already active, focusing it won't trigger `on_activate`.
|
||||
safe_listener_attach(TEXT_LISTENER, vbuff.view.buffer())
|
||||
else:
|
||||
self.window.focus_view(vbuff.view)
|
||||
vbuff = buffers.register(buff_ctl, vws)
|
||||
vbuff.sync(TEXT_LISTENER)
|
||||
|
||||
sublime.set_timeout_async(_)
|
||||
|
||||
|
||||
|
|
|
@ -143,16 +143,18 @@ class BufferRegistry():
|
|||
|
||||
def register(self, bhandle: codemp.BufferController, wsm: WorkspaceManager):
|
||||
bid = bhandle.path()
|
||||
# tmpfile = os.path.join(wsm.rootdir, bid)
|
||||
# open(tmpfile, "a").close()
|
||||
|
||||
win = sublime.active_window()
|
||||
view = win.open_file(bid)
|
||||
while view.is_loading():
|
||||
pass # yes spinlock, fite me.
|
||||
newfileflags = sublime.NewFileFlags.TRANSIENT | sublime.NewFileFlags.ADD_TO_SELECTION | sublime.NewFileFlags.FORCE_CLONE
|
||||
view = win.new_file(newfileflags)
|
||||
|
||||
|
||||
view.set_scratch(True)
|
||||
# view.retarget(tmpfile)
|
||||
view.set_name(os.path.basename(bid))
|
||||
syntax = sublime.find_syntax_for_file(bid)
|
||||
if syntax:
|
||||
view.assign_syntax(syntax)
|
||||
|
||||
view.settings().set(g.CODEMP_VIEW_TAG, True)
|
||||
view.settings().set(g.CODEMP_BUFFER_ID, bid)
|
||||
view.set_status(g.SUBLIME_STATUS_ID, "[Codemp]")
|
||||
|
|
Loading…
Add table
Reference in a new issue