-
Notifications
You must be signed in to change notification settings - Fork 701
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 toggle? #922
tail toggle? #922
Comments
This is actually something we've discussed; a very good use case for xi right now would be as a log viewer, and reading long log files is a good stress test. |
How far does our autoreload get us here? I imagine it'd work fine (minus staying scrolled to the bottom) until the file starts taking noticeable time to read. |
Yea, our autoreload is doing a whole-file read, so it wouldn't be great in the huge-log case, but it's a reasonable place to start. I could imagine a 'log mode', which would automatically adjust the scroll as new content arrived, but would disable itself if the user manually scrolled elsewhere (and re-enable itself if the user manually scrolled back to the bottom of the buffer?) |
@cmyr Log mode behavior you are talking about is exactly what I had in mind. |
@sjoshid cool, feel free to ask questions here as they arise. 👍 |
Just an update. Nothing super important. I was able to setup notify feature and see how current autoreload works. Im still learning concepts widely used like Editor, View, Buffer, Ropes and so on. |
@sjoshid cool, glad you're making progress! If you have any questions I'm happy to help. |
@cmyr Thanks for offering to help. |
@sjoshid Currently, The problem is that we don't necessarily know what part of the buffer has changed, so we have to figure that out. the way that |
So basically, if a file is open in 'tail' mode, you want to note that somewhere, and then you want to have different logic in |
Great. That helps. Will focus on |
@cmyr |
yes, you will need to generate a delta with the newly loaded contents and apply that to the engine. If you have a // in editor.rs
fn tail_append(&mut self, tail: Rope) {
let buf_end = self.text.len();
let mut builder = DeltaBuilder::new(buf_end);
builder.replace(buf_end..buf_end, tail);
self.apply_delta(builder.build());
} |
Tailing a file with notify feature.
@cmyr One issue Im still working on: Xi tails even when I run without notify. This condition |
I'm somewhat surprised that even compiles as I've only ever seen |
@sjoshid Can you open a PR with this, and then I'll take a look? |
Notify shouldn't be here. It was already under core-lib.
Refactoring and cleanup.
Removing unused import.
Removing unused import.
I created a PR but it is failing because of rustfmt. So I tried formatting using that but ran into another issue. Rustfmt config documentation is correct. Looks like an issue with rustfmt. Anyone else facing this error? |
I suspect this is related to the version of rust you're running; we run edit: and thanks for the PR, i'll take a look! |
That was it. Thanks. |
@sjoshid Okay, so I think that for now it makes more sense to have 'tail' be something that we can turn on for already-open files; this should be simpler to implement and test; I'd just add a I'm not sure what's going on with notify, however I wouldn't use that feature to determine whether this is enabled; Another question here is whether or not 'tail' implies that a file is read-only. Realistically, I think it does; we can't reload changes if we've changed the file ourselves, so I don't think it makes sense for us to allow editing in this case. Adding 'read-only' support would be a feature in itself, (and there's an old issue at #196) so it's out of scope for this PR, but something to keep in mind. In any case, I think a good first goal for this work is to have a 'Tail Toggle' item in the Debug menu of xi-mac that will start tailing the currently open file. I think once that is working we can think more seriously about what it will take to get this merged. Sound reasonable? |
Sounds good.
I did fiddle with notify initially, but later realized notify is turned on by default. Main reason why im checking if it's on/off is to make sure I don't break things I dont know about (like fuchsia). Im referring to
Valid point. Im on Linux using xi-gtk so behavior I see might be different from xi on mac. When tailing a file if I make changes....xi stops tailing! It not just stops tailing it wont allow me to save the file either. This behavior is similar to vscode and atom. They do allow editing a file being tailed just like xi does. So I guess what you are saying here is the current behavior is fine and we dont have to worry about read-only for this PR? The main intention of this PR was to improve performance of |
Ohh and I just remembered, I already had something similar to debug option you are talking about. It's in struct TailDetails called |
Ah okay I didn't realize you were on xi-gtk. You're correct that if you edit the file tail will get 'cancel'ed (it will still try to reload but will abort when it sees there are unsaved changes) so maybe this is reasonable behaviour. When I talk about a 'debug' setting I mean an RPC, prefixed with 'debug', that we can test the feature with. This is an internal convention for things that are still in flux. On xi-mac, we have a 'debug' menu where we cram a bunch of stuff: And if you were working on this feature on xi-mac I'd suggest you add a 'tail' command there. In any case, it would be nice to have a command that is exposed from a menu that lets you toggle this feature; we'll need that eventually and it makes testing much easier. |
Sounds good. Will make necessary changes in same PR.
On Sun, Nov 25, 2018 at 11:35 PM Colin Rofls ***@***.***> wrote:
Ah okay I didn't realize you were on xi-gtk. You're correct that if you
edit the file tail will get 'cancel'ed (it will still try to reload but
will abort when it sees there are unsaved changes) so maybe this is
reasonable behaviour.
When I talk about a 'debug' setting I mean an RPC, prefixed with 'debug',
that we can test the feature with. This is an internal convention for
things that are still in flux. On xi-mac, we have a 'debug' menu where we
cram a bunch of stuff:
[image: debug menu]
<https://user-images.githubusercontent.com/3330916/48993201-6322eb80-f10a-11e8-866a-10baad89096c.png>
And if you were working on this feature on xi-mac I'd suggest you add a
'tail' command there.
In any case, it would be nice to have a command that is exposed from a
menu that lets you toggle this feature; we'll need that eventually and it
makes testing much easier.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#922 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGcDchNswokD5JtxakuWGMhLkpN5Mw1yks5uy2-NgaJpZM4XbWDo>
.
--
Thank you.
- Sujit Joshi.
|
Often times I have felt the need to tail a file for some time and then stop and start again. Would it be possible for Xi core to support tailing a file on demand? Of course there are other ways to do this, like open a terminal within the editor and tail from there. But Im thinking of a tail mode in Xi which can be turned on/off.
The text was updated successfully, but these errors were encountered: