Bug 465064

Summary: Multiple windows always have the same files open
Product: [Applications] kate Reporter: Alex Kodat <akodat>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: waqar.17a
Priority: NOR    
Version: 22.04.3   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Alex Kodat 2023-01-30 22:46:45 UTC
SUMMARY
***
On my new M1 Mac (Ventura 13.2) whenever I open a new Window in Kate, the files I have open in other windows are opened there too and as I open and close files in one window the other windows generally open and close those files too (though weirdly, sometimes a close is *not* reflected in other windows). 
***
I've run Kate (and love it!) on KDE (wish my company would let me run Linux/KDE :-() and on Windows and switched to a Mac and this behavior is driving me batty as it totally defeats the purpose of multiple Windows. After all, what good do multiple windows do if they're identical. I understand that macOS's disdain for multiple instances of a program is annoying and probably could be worked around to produce the behavior I'd like with multiple instances but having multiple independent Windows would be far tidier.

STEPS TO REPRODUCE
1. Open a few files in a Kate window under macOS (multiple tabs)
2. Open another window -- all files open in original window are open in new one. :-(
3. Open additional files in any window opens them in all windows. :-(

OBSERVED RESULT

New windows have all files open that current window had. File opens and closes reflect in all windows.

EXPECTED RESULT

Each window's open files are independent and a new window starts with no open files.

SOFTWARE/OS VERSIONS
macOS: 

ADDITIONAL INFORMATION
Comment 1 Waqar Ahmed 2023-02-09 06:35:46 UTC
You need to upgrade to 22.12, the behaviour you note has changed/improved significantly :)
Comment 2 Alex Kodat 2023-02-09 13:56:56 UTC
(In reply to Waqar Ahmed from comment #1)
> You need to upgrade to 22.12, the behaviour you note has changed/improved
> significantly :)

Thanks Waqar. Now on 22.12 and it is, indeed, better. I can open and close files in separate windows pretty independently. But when I open a new window, it still starts out with all the files open on my previous window. So if I'm editing 8 files (8 tabs) and decide I'd like a clean window for editing files, elsewhere, I open a new window and, argh, I have 8 files open plus an untitled tab. So the first thing I have to do in the new window is go to each tab and close the file already open in another window. Not the end of the world, but pretty annoying.

Again, if I have a file open in one window, why the heck would I want that file open in a new window? Windows are useful for organizing editing sessions and having the same files open in multiple windows defeats this.
Comment 3 Waqar Ahmed 2023-02-09 15:12:16 UTC
> But when I open a new window, it still starts out with all the files open on my previous window. So if I'm editing 8 files (8 tabs) and decide I'd like a clean window for editing files, elsewhere, I open a new window and, argh, I have 8 files open plus an untitled tab.

I can't reproduce that (with version 22.12.1). When I open a new window, its clean i.e. no existing tabs. Can you check again?
Comment 4 Waqar Ahmed 2023-02-09 15:23:25 UTC
Trying again, it is reproducible if you are running a named session.
Comment 5 Alex Kodat 2023-02-09 16:26:49 UTC
OK, I think maybe I was just being stupid. I think I was hitting ⌘N to start a new window rather than F1. ⌘N opens a new window on most apps that support windows (like Chrome) but it makes sense that it creates a new file under Kate. But.. 

Windows are still really a struggle. I can't, for the life of me, see a way of closing a window once it's been opened. ⌘Q or clicking on the close window button closes all Kate windows. Even worse, after I do that Kate (or macOS?) very helpfully opens all the windows I had opened before I exited Kate (with nothing open in any of them). I can uncheck "Include window configuration" in session management but that cure is worse than the disease as it causes kate to forget all my window size and toolbar settings. In fact, that's another annoyance when I open a new window, it doesn't seem to inherit toolbar settings from my current window. I would expect toolbar settings to apply to all windows as they're kind of a personal preference that's not likely to change as one moves between windows.

Should I open a new ticket (new tickets)?
Comment 6 Waqar Ahmed 2023-02-09 16:47:34 UTC
> rather than F1

That doesn't sound like a default shortcut provided by us. Default shortcut (linux) is Ctrl+Shift+N.

Also, Ctrl + Q => quits the application, so yes, that will quit all windows. The window close button (usually three buttons on top left/right corner of the window), will just close the window not Kate itself.

>  I would expect toolbar settings to apply to all windows as they're kind of a personal preference that's not likely to change as one moves between windows.

That should happen, yeah.

Yes, for every issue you find feel free to open a new tickets. With such issues, it helps if there is a video recording of the issue.
Comment 7 Bug Janitor Service 2023-02-09 17:37:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1101
Comment 8 Christoph Cullmann 2023-02-09 20:45:50 UTC
Git commit eec336f661ed8a4ba3fa305163904ff5b4b92dc3 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 09/02/2023 at 20:35.
Pushed by cullmann into branch 'master'.

Only restore views for first main window

We changed the behaviour in last release so that new mainwindows dont
bring views of last mainwindow. However, it doesn't work if you are using
a named session as it will just keep restoring huge lists of views for
every new window

M  +2    -2    apps/lib/kateapp.cpp
M  +2    -1    apps/lib/kateapp.h
M  +3    -3    apps/lib/katemainwindow.cpp
M  +2    -1    apps/lib/katemainwindow.h

https://invent.kde.org/utilities/kate/commit/eec336f661ed8a4ba3fa305163904ff5b4b92dc3
Comment 9 Christoph Cullmann 2023-02-17 20:47:02 UTC
Git commit 23eb0e567d2e4321b9c59a148e2e4b3a9c13f082 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 17/02/2023 at 20:40.
Pushed by cullmann into branch 'master'.

Save global options of active window before creating new

So that the new window shows anything that was changed by the user e.g.,
if the user hid the tabbar and created a new window, the new window
should have the tabbar hidden.

With this change we save the options as soon as the user checks/unchecks
one of the options under "Settings" menu
Related: bug 464639

M  +27   -0    apps/lib/autotests/kate_view_mgmt_tests.cpp
M  +1    -0    apps/lib/autotests/kate_view_mgmt_tests.h
M  +4    -0    apps/lib/katemainwindow.cpp

https://invent.kde.org/utilities/kate/commit/23eb0e567d2e4321b9c59a148e2e4b3a9c13f082
Comment 10 Waqar Ahmed 2023-02-26 10:49:55 UTC
Git commit a84fbe4910230ef029c40c19c85aa6a402622370 by Waqar Ahmed.
Committed on 26/02/2023 at 10:43.
Pushed by waqar into branch 'release/22.12'.

Save global options of active window before creating new

So that the new window shows anything that was changed by the user e.g.,
if the user hid the tabbar and created a new window, the new window
should have the tabbar hidden.

With this change we save the options as soon as the user checks/unchecks
one of the options under "Settings" menu
Related: bug 464639

M  +27   -0    apps/lib/autotests/kate_view_mgmt_tests.cpp
M  +1    -0    apps/lib/autotests/kate_view_mgmt_tests.h
M  +4    -0    apps/lib/katemainwindow.cpp

https://invent.kde.org/utilities/kate/commit/a84fbe4910230ef029c40c19c85aa6a402622370