-
Notifications
You must be signed in to change notification settings - Fork 700
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 v2 #1241
base: master
Are you sure you want to change the base?
Tail toggle v2 #1241
Conversation
2) Notify client about tail enable/disable.
@cmyr
But these arent issues that will stop you from reviewing. If there is something you want me to do make it easier for you to review...let me know. |
# Conflicts: # rust/core-lib/src/watcher.rs
…tail_toggle_v2 � Conflicts: � rust/core-lib/src/watcher.rs
2) Added a check to ignore rpc tail calls for files that dont exist.
…into tail_toggle_v2
EventKind::Modify(ModifyKind::Any) if event.flag().is_some() => { | ||
let flag_kind = event.flag().unwrap(); | ||
|
||
if Flag::Ongoing.eq(flag_kind) { |
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.
Ongoing
events should not be handled here.
@@ -869,8 +882,30 @@ impl View { | |||
let height = self.line_of_offset(text, text.len()) + 1; | |||
let plan = RenderPlan::create(height, self.first_line, self.height); | |||
self.send_update_for_plan(text, client, styles, style_spans, &plan, pristine); | |||
if let Some(new_scroll_pos) = self.scroll_to.take() { | |||
let (line, col) = self.offset_to_line_col(text, new_scroll_pos); | |||
if !self.is_tail_enabled { |
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 check makes sure that when user scrolls a tailing file, we dont auto scroll to cursor location. Mimics tail
command.
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 suppose it'd be worth adding a comment to the source file about this.
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.
Will do.
let mut inner = | ||
watcher(tx_event, Duration::from_millis(100)).expect("watcher should spawn"); | ||
inner | ||
.configure(Config::OngoingEvents(Some(Duration::from_millis(50)))) |
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.
Any mills less than 100 would made sense here.
return Ok(Rope::from("")); | ||
} | ||
|
||
let existing_file_info = self.file_info.get(&id).expect("File info must be present"); |
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.
Using expect
here is kind of ugly.
f.seek(SeekFrom::End(0)).map_err(|e| FileError::Io(e, path.as_ref().to_owned()))?; | ||
|
||
let current_position = file_info.tail_position.expect( | ||
"tail_position is None. Since we are tailing a file, tail_position cannot be None.", |
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.
Again, expect
here isn't nice
); | ||
let diff = end_position - current_position; | ||
let mut buf = vec![0; diff as usize]; | ||
f.seek(SeekFrom::Current(-(buf.len() as i64))).unwrap(); |
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.
Isn't buf.len() == diff here?
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.
Also, it'd be nice if we could avoid unwrap
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.
Isn't buf.len() == diff here?
yes.
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.
So it'd make more sense to just use diff here directly I think
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. Will make the change.
}; | ||
|
||
let has_changes = self.file_manager.check_file(path, buffer_id); | ||
let is_pristine = self.editors.get(&buffer_id).map(|ed| ed.borrow().is_pristine()).unwrap(); |
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.
Again, unwrapping isn't nice (unless None is a programmer error in which case the called code should probably panic!
anyway)
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.
Agree but this code is copied as is from original.
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.
Hm, I guess this returning None doesn't really happen then? @cmyr
@@ -869,8 +882,30 @@ impl View { | |||
let height = self.line_of_offset(text, text.len()) + 1; | |||
let plan = RenderPlan::create(height, self.first_line, self.height); | |||
self.send_update_for_plan(text, client, styles, style_spans, &plan, pristine); | |||
if let Some(new_scroll_pos) = self.scroll_to.take() { | |||
let (line, col) = self.offset_to_line_col(text, new_scroll_pos); | |||
if !self.is_tail_enabled { |
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 suppose it'd be worth adding a comment to the source file about this.
Could you please rebase this on master? |
I have already rebased this on master. You shouldnt get any conflicts. |
Closes #922
Review Checklist
cargo test --all
/./rust/run_all_checks
.