-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix link doc to envir #3764
fix link doc to envir #3764
Conversation
Instead of relying on user code, test if the document is in front, and push the environment correctly if this is the case. Save the current environment only if we are not already in a document that has a saved environment. We add a getter for `savedEnvir` for introspection. #testing: Test all methods that rely on setting the environment of a document.
This implicit setter broke `didBecomeKey`. It was probably a leftover from past revisions. This fixes supercollider#3760. #testing: Test calls to Document.current
This argument (`pushNow`) can be a very confusing option when set to false. It creates a document which will be linked properly to the environment only after losing focus and then coming back. For documents that are not in focus, on the other hand, it is much better not to push. This avoids user errors. This is an API change. #testing: Test calls of linkDoc and unlinkDoc to subclasses of EnvironmentRedirect, e.g. ProxySpace.linkDoc. As this is an API change, it might change the behaviour of user code (though it now behaves as probably used in most cases, and was broken before).
can you provide a test case please? ;) |
sorry, I was too fast... there's a test class and I'll have a look at how to deal with it (following advice in |
yes, it doesn't adhere to the "only one assert per method" rule. The resulting code would be much harder to read, because one test relies on the state of the previous. |
It would be good if you could test it also "by hand", maybe just with |
@LFSaw I've improved the tests a bit. |
(( side note if you name your PRs/branches |
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.
TestDocumentEnvir.runAll
resulted in no errors.TestEnvironmentDocument.runAll
resulted in no errors.
testing "by hand"
- create four documents, evaluate their content.
- switching between documents results in correct environment being printed
// 1
// ProxySpace behaviour
ProxySpace(s).linkDoc;
Document.current.toFrontAction = {currentEnvironment.postln}
// 2
// explicitely link current Einvironment
currentEnvironment.linkDoc;
Document.current.toFrontAction = {currentEnvironment.postln}
// 3
// arbitrary Envir
(test: true).linkDoc;
Document.current.toFrontAction = {currentEnvironment.postln}
// 4
// default case
Document.current.toFrontAction = {currentEnvironment.postln}
} | ||
|
||
|
||
TestEnvironmentDocument : UnitTest { |
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.
Is this the correct Naming scheme?
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.
I supposed that this is reasonable. So far, we haven't been very systematic about it.
re side note: github desktop doesn't permit slashes for whatever reason |
This fixes #3717.
The basic assumption is that only one document can be in focus.
currentEnvironment
. Whatever envir that was current at that time should be saved.currentEnvironment
, so that it is in a consistent state.