-
Notifications
You must be signed in to change notification settings - Fork 301
Conversation
Also check that there are valid windows to swap to, both initially and after filtering.
This is awesome, @CrossR ! Once we have this I might never need to leave Oni... I'll put browser and terminal in one window and code in the other haha
Tested it out, worked perfectly moving right/left between my two monitors 👍
Thanks for thinking about the tests! The CiTests may be tricky - we don't have any tests that launch multiple Oni instances today, and in automation, we don't force a single instance of the It would be nice to have a full CiTest eventually, but I'm not sure it's the right tradeoff of value vs time at the moment (up to you though). Other bullet points look great - excited to have this in! |
Codecov Report
@@ Coverage Diff @@
## master #1747 +/- ##
==========================================
+ Coverage 42.37% 42.46% +0.09%
==========================================
Files 163 165 +2
Lines 6252 6349 +97
Branches 881 889 +8
==========================================
+ Hits 2649 2696 +47
- Misses 3429 3477 +48
- Partials 174 176 +2
Continue to review full report at Codecov.
|
Not sure if this should be the default or not. Is possible we could hook up a config option and pass that over the IPC to here to make it configurable.
It looks like the error I get isn't due to the Need to look into why that is happening, and how to fix it... |
It seems that for some reason, when the main Window is closed, the first item in the |
Ah, interesting. I think I see one problem (it's really an existing bug, just easier to hit now with this change). The repro I did was open two Oni instances:
It looks like the issue is this line here:
The problem is that, A quick fix is to hold a reference to the current window in the closure:
And then use that in the filter:
It might be good eventually to get rid of the |
Added function to get current active window, and renamed main window to currentWindow.
I.e. always move to the closest window on the right.
@@ -84,7 +84,9 @@ ipcMain.on("move-to-next-oni-instance", (event, direction: string) => { | |||
// Keep a global reference of the window object, if you don't, the window will | |||
// be closed automatically when the JavaScript object is garbage collected. | |||
let windows: BrowserWindow[] = [] | |||
let mainWindow: BrowserWindow = null | |||
const activeWindow = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid! Thanks for fixing this 👍
I've added tests for all the easily testable parts. The remaining function that hasn't been tested doesn't return anything, so we'd need a CI test that can check the focus of a window, which sounds pretty awkward. Only thing left here I think is I want to check is that where I've added the subscription makes sense in Oh and the original ticket mentions adding commands for Expand Up/Down etc, but I think that is distinct enough to be done in a separate PR. Could probably also do with making the movement into an action that users can bind, such that a user can use it without having to move to the edge of the window with their own keybinds. |
|
||
// Given a window, check if it is the best window seen so far. | ||
// This is determined by the difference in X and Y relative to the current window. | ||
export function checkWindowToFindBest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! Great set of unit tests covering this functionality.
"test:unit:browser": "npm run build:test:unit && cd browser && electron-mocha --renderer --require testHelpers.js --recursive ../lib_test/browser/test", | ||
"test:unit": "npm run test:unit:browser && npm run test:unit:main", | ||
"test:unit:browser": "npm run build:test:unit:browser && cd browser && electron-mocha --renderer --require testHelpers.js --recursive ../lib_test/browser/test", | ||
"test:unit:main": "npm run build:test:unit:main && cd main && electron-mocha --renderer --recursive ../lib_test/main/test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for setting this up! 💯
@@ -170,6 +171,10 @@ export class OniEditor implements IEditor { | |||
buf => extensions.includes(path.extname(buf.filePath)), | |||
buf => new ImageBufferLayer(buf), | |||
) | |||
|
|||
windowManager.onUnhandledMove.subscribe((direction: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw your comment - there is one problem with the location here. In the 'multiplexing' scenario (when editor.split.mode
is 'oni'
), we will potentially have multiple OniEditor
instances - so that means this would get fired multiple times.
One option would be to plop this code in browser/src/index.tsx
, after we've created the WindowManager
. Or add an activate
method in MultiProcess
, like we have for some of the other services, pass in the windowManager
as a dependency, and wire up the event there.
Awesome! Thanks for wiring up unit tests for our
Agree 100% - I don't think a CiTest is necessary for this.
Ah ya, good catch - there might be an issue in the 'multiplexing' case - I left a more detailed comment on the file. But we probably will want to move it to a place that only gets initialized once.
Yep, makes sense to have that be a separate PR 👍 Nice work! 💯 |
Assuming no failures on the CI side of things, this should be done now. |
Awesome! Code changes look great 👍 Approving now |
Potentially fixes #67.
I've not actually got 2 monitors, so I've written this such that it should work broadly moving across any Oni instances. Plus I don't think the screen number actually matters since I think if you have 2 1080p monitors, the top left of your primary is 0,0 and then the other ones are either
-1920,0
or1920,0
, so this approach (ie using the current location) should work.That said! I don't want to put a bunch of effort in based on vague assumptions I've had from reading StackExchange and GitHub issues, so if someone with 2 monitors could test it, that would be great. Currently, I've not bothered hooking up the movement keys, I'm just using the
Ctrl+Shift+P
menu to add Up, Down, Left, Right movements.Assuming that works on multiple monitors, since it works for me on one at least:
windows
being correctly emptied, since currently if you close a Window, this stops working due to an object being destroyed.If not, well at least I only spent an hour or so on this to avoid other work.