-
Notifications
You must be signed in to change notification settings - Fork 147
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
Tail feature #486
base: master
Are you sure you want to change the base?
Tail feature #486
Conversation
Removing toggleTailConfigChanged added as a dup during merge.
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.
The PR looks much better! I have a few remaining comments before I'm ok with merging this, though I think it's pretty close already.
@@ -711,6 +717,10 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |||
document.xiCore.setTheme(themeName: sender.title) | |||
} | |||
|
|||
@IBAction func debugToggleTail(_ sender: NSMenuItem) { | |||
document.xiCore.toggleTailConfig(identifier: document.coreViewIdentifier!, enabled: !self.isTailEnabled) |
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.
We could probably rewrite this in a way so we don't have to do !self.isTailEnabled
here, since it feels counter intuitive.
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.
Rewrite how?
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.
This is just a little nit, but I'd prefer if this was
document.xiCore.toggleTailConfig(identifier: document.coreViewIdentifier!, enabled: self.isTailEnabled)
Sources/XiEditor/Client.swift
Outdated
@@ -86,4 +86,7 @@ protocol XiClient: AnyObject { | |||
|
|||
/// A notification containing the current replace status. | |||
func replaceStatus(viewIdentifier: String, status: ReplaceStatus) | |||
|
|||
/// A notification telling toggle tail config was successfully changed. | |||
func toggleTailConfigChanged(viewIdentifier: String, isTailEnabled: Bool) |
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.
Why is this toggleTailConfigChanged
? Do you envision the tail config to have more things than whether if the user enables tailing? Even if so, I feel like this should just be something like enableTailing
.
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.
Ok. I have made this change.
|
1) "Tail" option under Debug is grayed out if a file doesnt exist. No point in tailing such files. 2) Refactoring based on comments.
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.
Few more comments, and then I think this is in a good enough state to merge after the core PR goes in!
@@ -711,6 +717,10 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |||
document.xiCore.setTheme(themeName: sender.title) | |||
} | |||
|
|||
@IBAction func debugToggleTail(_ sender: NSMenuItem) { | |||
document.xiCore.toggleTailConfig(identifier: document.coreViewIdentifier!, enabled: !self.isTailEnabled) |
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.
This is just a little nit, but I'd prefer if this was
document.xiCore.toggleTailConfig(identifier: document.coreViewIdentifier!, enabled: self.isTailEnabled)
@@ -919,6 +951,11 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |||
languagesMenu.addItem(item) | |||
} | |||
} | |||
|
|||
public func enableTailing(_ isTailEnabled: Bool) { | |||
self.isTailEnabled = isTailEnabled |
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.
.. and this part is instead:
self.isTailEnabled = !isTailEnabled
This avoids having to rely on state from another method.
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.
See my long comment below.
@@ -228,6 +229,11 @@ enum CoreNotification { | |||
{ | |||
return .replaceStatus(viewIdentifier: viewIdentifier!, status: replaceStatus) | |||
} | |||
case "enable_tailing": | |||
if let isTailEnabled = jsonParams["is_tail_enabled"] as? Bool |
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 think enable_tailing
should be toggle_tailing
instead, since it's way clearer in conveying what it does exactly. enable_tailing
implies that it always enables tailing for any file, not what it actually does (which is toggle the tailing state for a specific view).
Since you changed this here, your plugin doesn't handle the old JSON properly. Perhaps you should update your other PR as well with this change?
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 havent push the change. I'll do it based on outcome of the naming discussion we are having.
@nangtrongvuon I still think If you want me to separate enable and disable I would have to do something like
If this is what you want, I would be happy to make the change. If not, let me know what you think. Sorry about long comment. I hope Im not going off on a tangent. |
My main problem with this:
Is that you begin to mutate state in a method's argument which I think reads really weird. It doesn't produce the wrong results, but it's also something I'm not okay with seeing in a codebase, since it makes following this code hard and also makes it less maintainable. I'm also not a fan of using this frontend boolean to determine behavior of core. I believe this is a code smell, and core should be able to maintain which views are currently being tailed. The frontend doesn't really need to control this state, at most it should only communicate that state to the user (for xi-mac, this should be the So in conclusion, I wouldn't split it into |
Closes xi-editor/xi-editor#922.
This PR adds a "Tail File" option under Debug menu. This option can be enabled/disabled per file.
TODO: Gray out this option if the file doesnt exist. No point in tailing a file that doesnt exist.Review Checklist