sublime-emacs/sublemacspro

Sublime Text 4 window splitting behavior

Remillard opened this issue · 14 comments

I think there's something strange going on here and I suspect it has something to do with the new multi-tab select behavior in ST4. For the following discussion I'm using 'window' and 'frame' in the Emacs parlance where 'window' means a subdivision in the editing zone, and 'frame' is the normal Windows window instance.

If I have a buffer open, and I hit C-x 3, I expect the window to split down the middle and the buffer is duplicated in both window in the frame. That's what happens in Emacs and that's what used to happen in Sublime Text 3.

In ST4, if I hit C-x 3, the frame splits correctly, however the buffer does not duplicate in the side buffer.

Using C-x o does correctly move the point between the two windows it seems even though the buffer doesn't duplicate.

Using C-x 1 in any window should close all other windows and make the buffer become the whole window. I seem to remember this working in ST3 but I don't have a way to test it right now. In ST4 though, C-x 1 will just return the point to the leftmost window.

Coming from the other side, if the user selects multiple tabs, it'll split the window as if you split and changed buffers, however, controls like C-x o do not work -- presumably because this operation happened outside of Emacs Pro Essentials creating these objects. I don't know if this behavior can be queried or trapped, but it's something to keep in mind.

That's all I've found so far!

I noticed this as well. I will try to fix it but some underlying APIs have changed and I have been too busy to address this problem.

And I am not willing to go back to ST3, either.

So I am quite motivated to fix it.
\

OK - it's working again.

I have some work to do on the "delete current window" command (Ctrl-X D).

Do you have the means to edit your local copy of this package? I am not ready to release it yet.

Here are the diffs:

$ git diff
diff --git a/jove.py b/jove.py
index 5db742c..090fb4c 100644
--- a/jove.py
+++ b/jove.py
@@ -977,10 +977,16 @@ class SbpPaneCmdCommand(SbpWindowCommand):
             return False
 
         window.set_layout(lm.build())
+        print("SET LAYOUT")
+
+        window.focus_group(current)
+        print("FOCUS GROUP")
 
         # couldn't find an existing view so we have to clone the current one
         window.run_command("clone_file")
 
+        print("CLONED")
+
         # the cloned view becomes the new active view
         new_view = window.active_view()
 
@@ -1004,7 +1010,9 @@ class SbpPaneCmdCommand(SbpWindowCommand):
             new_view.show(point)
             view.show(point)
 
-        sublime.set_timeout(setup_views, 10)
+        setup_views()
+        window.focus_view(new_view)
+

Obviously you can delete the print(...) statements.

(Didn't mean to close the issue ...)

That's alright. I had just reinstalled ST due to having a ton of old packages I didn't use and even Package Control wasn't working very well at that point. I don't have the Resource Editor at the moment.

If you've got this in a branch though I might be able to just remove the EPE package, clone the repo into the User folder (that's what I do for my VHDL Mode package) but I have to get the name just right.

Also got moved to a project in crisis, so yeah I'm pretty low on time myself. I'll try though when I can and report back. The more I do, the more annoying I find it that the split doesn't maintain the prior buffer. I guess I used that feature a LOT because I tended to keep one viewport into the buffer up around signal declarations, and the other down where I was actively editing code and I really miss that capability :D

Checked, doesn't seem like you've made a branch for this. I'll see if I can just clone it and make your change directly to jove.py.

Yeah I think this change is working for me right now. I'll keep playing with it for a bit. Now that I am running off cloned repository versus the package control version, I'll have to keep an eye out for a release to go back to the distributed package.

Definitely might need some sort of context switch for that. Or perhaps the file that Package Control uses to sort packages has some tags for versions. Might be able to keep the current EPE release for all versions prior to 4, and then for current and future versions continue to use the last release. It's been too long but I think there's a way to do that, would check with the guys on the Discord on the best way to structure that. Surely you're not the only one with a package that needs to split versions.

I don't see anything wrong with C-d as it seems to delete for me correctly but then maybe there's something else going on in a functionality I don't use.

Aha. Well definitely doesn't do that for me. I wonder if the Sublime Text 4 keybind is getting run before the EPE keybind for C-d. I haven't run with standard ST keybinds in so long, I don't know what the usual keys are for manipulations.

OK - it's working again.

I have some work to do on the "delete current window" command (Ctrl-X D).

Do you have the means to edit your local copy of this package? I am not ready to release it yet.

Here are the diffs:
[...]
Obviously you can delete the print(...) statements.

I tested your patch (it doesn't apply cleanly anymore, but it was a trivial thing to fix). It works for me in ST4, thanks!

Here's an updated patch, against master: p.diff.txt

I am swamped and not entirely up to speed. Delete current window is failing for me as described earlier in this thread.

Also when I kill the current window that needs saving, the window changes to another buffer while asking the question, which is very distracting.

Also, I am thinking of making the kill window function not keep the view around if the underlying buffer is marked as dirty, but instead, mark the underlying buffer as a tmp buffer or whatever it's called, deleting the window, and then putting it back to a regular buffer. That is, if there's another view somewhere that is displaying the same buffer.