Skip to content
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

Continuation of Add search bar at bottom of revlog #506 #672

Closed
wants to merge 102 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
f70b92a
Add search bar at bottom of revlog
WizardOhio24 Feb 4, 2021
2a5d9a8
Add esc to escape and fix invisible commit details
WizardOhio24 Feb 4, 2021
5cc8e7d
Remove unused lines
WizardOhio24 Feb 4, 2021
be0c76f
Fix revlog
WizardOhio24 Feb 4, 2021
bd5123a
Fix vim keys test
WizardOhio24 Feb 4, 2021
3414a05
Allow searching to happen live rather than press enter
WizardOhio24 Feb 4, 2021
07f4ec1
Filter commits in selected_entry
WizardOhio24 Feb 4, 2021
e8a6db5
Fix naming
WizardOhio24 Feb 4, 2021
95e3a70
Remove unused command
WizardOhio24 Feb 4, 2021
709b501
Allow escaping with esc again
WizardOhio24 Feb 4, 2021
b06a716
Auto set focus on filter commit to true
WizardOhio24 Feb 4, 2021
bfbcc9a
If filtering log get all commits
WizardOhio24 Feb 4, 2021
0e671b9
Change set total count to update total count in commitlist
WizardOhio24 Feb 4, 2021
1b1c6ee
Change key to bring up find commit box to :
WizardOhio24 Feb 4, 2021
21904ea
Don't show char count in find commit component
WizardOhio24 Feb 4, 2021
84ca7d2
Also filter by author
WizardOhio24 Feb 4, 2021
ab8770c
Add find commit to log commands
WizardOhio24 Feb 4, 2021
41c121e
esc on log tab to cancel search
WizardOhio24 Feb 4, 2021
56ef6be
Change search back to s
WizardOhio24 Feb 4, 2021
e6dd94a
Also update count when not filtering
WizardOhio24 Feb 4, 2021
b5fdceb
Fix h not working in text input
WizardOhio24 Feb 4, 2021
1ba3b23
Change tabs to spaces in keys.rs
WizardOhio24 Feb 4, 2021
504e0a9
Filter commits in commit log rather than commitlist
WizardOhio24 Feb 4, 2021
6930d73
Add extend item list to fetch commit
WizardOhio24 Feb 4, 2021
a505c05
Revert to 1ba3b23: Change tabs to spaces in keys.rs
WizardOhio24 Feb 4, 2021
db48ec5
Implement async filterer for commits
WizardOhio24 Feb 9, 2021
7c9fc66
Remove filter code from commitlist
WizardOhio24 Feb 9, 2021
9d3985d
Shutdown filter thread before starting another filter
WizardOhio24 Feb 9, 2021
47df534
Working async commit filter
WizardOhio24 Feb 9, 2021
b2d2f82
Fix async filter thread terminating upon finishing search
WizardOhio24 Feb 9, 2021
70ca71a
Set commit length when retrieving filtered commits
WizardOhio24 Feb 9, 2021
cd938f6
Finish filter if 0 recieved rather than <=1
WizardOhio24 Feb 9, 2021
fdf2fad
Make search case insensitive
WizardOhio24 Feb 9, 2021
d3abde6
Fix clippy warning
WizardOhio24 Feb 9, 2021
ebbe26e
Add a filter function using : in search to filter by sha, author or m…
WizardOhio24 Feb 9, 2021
16da8a0
Remove expect
WizardOhio24 Feb 9, 2021
0114cbf
Change async filter sleep durations
WizardOhio24 Feb 9, 2021
b4cf798
Trim whitespace
WizardOhio24 Feb 9, 2021
0be4840
Allow union filtering with ||
WizardOhio24 Feb 10, 2021
05c734c
Use rayon core for thread and add work pending
WizardOhio24 Feb 10, 2021
bf0d6ea
Fix sleep timings so filter runs quicker
WizardOhio24 Feb 10, 2021
933d4c5
Store state locally for quicker return if no work pending
WizardOhio24 Feb 10, 2021
9578e8d
Use refcell to fix is_pending
WizardOhio24 Feb 10, 2021
e9eeb53
Allow &&(intersection) and ||(union) filtering
WizardOhio24 Feb 11, 2021
f442c33
Use mutexes to prevent several threads filtering at once
WizardOhio24 Feb 11, 2021
ae01732
Clear filtered commits when starting a new search in thread
WizardOhio24 Feb 11, 2021
c5b469b
Use parking log mutex
WizardOhio24 Feb 11, 2021
8fc599d
Fix import order
WizardOhio24 Feb 11, 2021
524ddcc
Fix spinner up before filter
WizardOhio24 Feb 11, 2021
06d6ade
Remove filter_thread_running
WizardOhio24 Feb 11, 2021
7ed2cda
Remove unneeded comments
WizardOhio24 Feb 11, 2021
c444aaa
Make filter function more succinct
WizardOhio24 Feb 11, 2021
5bd747b
Remove clippy allow too many lines
WizardOhio24 Feb 11, 2021
8db4523
Fix brackets in filter function
WizardOhio24 Feb 11, 2021
a1cd020
Remove reset values from start_filter in main thread
WizardOhio24 Feb 11, 2021
126431a
Remove clear function from async filter
WizardOhio24 Feb 11, 2021
7a416de
Move try_recv to before getting slice of commits
WizardOhio24 Feb 11, 2021
d70e149
Add complement search
WizardOhio24 Feb 11, 2021
a2faf29
Support case sensitive filtering
WizardOhio24 Feb 12, 2021
571c401
Add comment to filter function explaining what input is expected
WizardOhio24 Feb 12, 2021
d5d24fb
Fix clippy warnings and not revlog filter by
WizardOhio24 Feb 12, 2021
712fb82
Fix filter if no leading :
WizardOhio24 Feb 12, 2021
529cc74
Support filtering by tags
WizardOhio24 Feb 13, 2021
f4f5b6e
Support brackets in search
WizardOhio24 Feb 13, 2021
9c51df3
Allow nested brackets
WizardOhio24 Feb 13, 2021
f6863d0
Fix clippy
WizardOhio24 Feb 13, 2021
a361c70
Fix clippy
WizardOhio24 Feb 13, 2021
a0b9af5
Support nested brackets and fix not tag search to show commits with n…
WizardOhio24 Feb 13, 2021
1647357
Remove unneeded comments
WizardOhio24 Feb 13, 2021
507d6f8
Small varible name change
WizardOhio24 Feb 13, 2021
32eb3e2
Reset LIMIT_COUNT in revlog to 3000
WizardOhio24 Feb 13, 2021
501a194
Remove unneeded logging
WizardOhio24 Feb 13, 2021
fe6d817
Remove amount argument from fetch_helper
WizardOhio24 Feb 18, 2021
447d095
Move comment above derive
WizardOhio24 Feb 18, 2021
e68938d
Create function get_tags
WizardOhio24 Feb 18, 2021
71582a7
Remove added ;
WizardOhio24 Feb 18, 2021
f933bf2
Add comment to get_ending_bracket
WizardOhio24 Feb 18, 2021
d1c3b54
Add comment to remove_out_brackets
WizardOhio24 Feb 18, 2021
1f133c7
Only re-filter if string is different
WizardOhio24 Feb 18, 2021
6124b9b
Add filter_string to new revlog
WizardOhio24 Feb 18, 2021
4b07b3a
Change back to set_total_count in commitlist
WizardOhio24 Feb 18, 2021
d70cc4f
Fix clippy warnings and change while to for in get_ending_bracket
WizardOhio24 Feb 18, 2021
2d3cf33
Fix search by trimming string
WizardOhio24 Feb 18, 2021
7b610b3
Add brackets round tag filter in async_filter
WizardOhio24 Feb 18, 2021
6ab22fa
Add search filter commits to readme
WizardOhio24 Feb 19, 2021
2a99ed5
Remove is_and && from filter
WizardOhio24 Feb 19, 2021
c777ef3
Remove ALT down to focus on search
WizardOhio24 Feb 19, 2021
3fe9a33
Remove comment about getting tags from start_filter
WizardOhio24 Feb 19, 2021
dd158e0
Remove continue filter comment
WizardOhio24 Feb 19, 2021
843ff3b
Merge branch 'master' into find-sha
WizardOhio24 Feb 25, 2021
b0ee951
Fix merge problems
WizardOhio24 Feb 25, 2021
82ce6fc
Add tests for `Revlog::get_what_to_filter_by`
willir Apr 25, 2021
f12fde4
Refactor, fix a few bugs(with space handling), and add documentation to
willir Apr 25, 2021
225a1a0
Merge remote-tracking branch 'extrawurst/master' into find-sha
willir Apr 25, 2021
6e31762
Use std::sync::Mutex instead of the one from parking_lot
willir Apr 25, 2021
efa44c2
Return original formating in KeyConfig::get_hint in src/keys.rs
willir Apr 25, 2021
47cdc09
Remove used AsyncCommitFilterer::filter_strings field
willir May 2, 2021
66e6209
Merge remote-tracking branch 'extrawurst/master' into find-sha
willir May 2, 2021
0afcc9e
Reformat with rustfmt
willir May 2, 2021
b0a7224
Merge branch 'master' into find-sha
willir May 8, 2021
38eeeeb
Fix clippy errors
willir May 8, 2021
99f0e0a
Merge remote-tracking branch 'extrawurst/master' into find-sha
willir May 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
- Stashing (save, pop, apply, drop, and inspect)
- Push/Fetch to/from remote
- Branch List (create, rename, delete, checkout, remotes)
- Browse commit log, diff committed changes
- Browse commit log, diff committed changes, search/filter commits
- Scalable terminal UI layout
- Async git API for fluid control

Expand Down
1 change: 1 addition & 0 deletions asyncgit/src/revlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub enum FetchStatus {
}

///
#[derive(Clone)]
pub struct AsyncLog {
current: Arc<Mutex<Vec<CommitId>>>,
sender: Sender<AsyncNotification>,
Expand Down
2 changes: 1 addition & 1 deletion asyncgit/src/sync/commits_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl From<Oid> for CommitId {
}

///
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct CommitInfo {
///
pub message: String,
Expand Down
1 change: 1 addition & 0 deletions asyncgit/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct TagsResult {
}

///
#[derive(Clone)]
pub struct AsyncTags {
last: Arc<Mutex<Option<(Instant, TagsResult)>>>,
sender: Sender<AsyncNotification>,
Expand Down
3 changes: 3 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ impl App {
self.push_tags_popup.push_tags()?;
flags.insert(NeedsUpdate::ALL)
}
InternalEvent::FilterLog(string_to_filter_by) => {
self.revlog.filter(&string_to_filter_by)?
}
InternalEvent::StatusLastFileMoved => {
self.status_tab.last_file_moved()?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/commitlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ impl CommitList {
}

///
pub fn set_count_total(&mut self, total: usize) {
self.count_total = total;
pub fn set_total_count(&mut self, count: usize) {
self.count_total = count;
self.selection =
cmp::min(self.selection, self.selection_max());
}
Expand Down
119 changes: 119 additions & 0 deletions src/components/find_commit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
use super::{
textinput::TextInputComponent, CommandBlocking, CommandInfo,
Component, DrawableComponent, EventState,
};
use crate::{
keys::SharedKeyConfig,
queue::{InternalEvent, Queue},
strings,
ui::style::SharedTheme,
};
use anyhow::Result;
use crossterm::event::Event;
use tui::{backend::Backend, layout::Rect, Frame};

pub struct FindCommitComponent {
input: TextInputComponent,
queue: Queue,
is_focused: bool,
visible: bool,
key_config: SharedKeyConfig,
}

impl DrawableComponent for FindCommitComponent {
fn draw<B: Backend>(
&self,
f: &mut Frame<B>,
rect: Rect,
) -> Result<()> {
self.input.draw(f, rect)?;
Ok(())
}
}

impl Component for FindCommitComponent {
fn commands(
&self,
_out: &mut Vec<CommandInfo>,
_force_all: bool,
) -> CommandBlocking {
CommandBlocking::PassingOn
}

fn event(&mut self, ev: Event) -> Result<EventState> {
if self.is_visible() && self.focused() {
if let Event::Key(e) = ev {
if e == self.key_config.exit_popup {
// Prevent text input closing
self.focus(false);
self.visible = false;
return Ok(EventState::Consumed);
}
}
if self.input.event(ev)?.is_consumed() {
self.queue.borrow_mut().push_back(
InternalEvent::FilterLog(
self.input.get_text().to_string(),
),
);
return Ok(EventState::Consumed);
}
}
Ok(EventState::NotConsumed)
}

fn is_visible(&self) -> bool {
self.visible
}

fn hide(&mut self) {
self.visible = false;
}
fn show(&mut self) -> Result<()> {
self.visible = true;
Ok(())
}

fn focus(&mut self, focus: bool) {
self.is_focused = focus;
}

fn focused(&self) -> bool {
self.is_focused
}

fn toggle_visible(&mut self) -> Result<()> {
self.visible = !self.visible;
Ok(())
}
}

impl FindCommitComponent {
///
pub fn new(
queue: Queue,
theme: SharedTheme,
key_config: SharedKeyConfig,
) -> Self {
let mut input_component = TextInputComponent::new(
theme,
key_config.clone(),
&strings::find_commit_title(&key_config),
&strings::find_commit_msg(&key_config),
false,
);
input_component.show().expect("Will not error");
input_component.set_should_use_rect(true);
Self {
queue,
input: input_component,
key_config,
visible: false,
is_focused: false,
}
}

pub fn clear_input(&mut self) {
self.input.clear();
}
}
3 changes: 3 additions & 0 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod cred;
mod diff;
mod externaleditor;
mod filetree;
mod find_commit;
mod help;
mod inspect_commit;
mod msg;
Expand All @@ -35,6 +36,7 @@ pub use create_branch::CreateBranchComponent;
pub use diff::DiffComponent;
pub use externaleditor::ExternalEditorComponent;
pub use filetree::FileTreeComponent;
pub use find_commit::FindCommitComponent;
pub use help::HelpComponent;
pub use inspect_commit::InspectCommitComponent;
pub use msg::MsgComponent;
Expand All @@ -47,6 +49,7 @@ pub use revision_files::RevisionFilesComponent;
pub use stashmsg::StashMsgComponent;
pub use tag_commit::TagCommitComponent;
pub use textinput::{InputType, TextInputComponent};
pub use utils::async_commit_filter;
pub use utils::filetree::FileTreeItemKind;

use crate::ui::style::Theme;
Expand Down
31 changes: 21 additions & 10 deletions src/components/textinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct TextInputComponent {
key_config: SharedKeyConfig,
cursor_position: usize,
input_type: InputType,
should_use_rect: bool,
current_area: Cell<Rect>,
}

Expand All @@ -61,6 +62,7 @@ impl TextInputComponent {
default_msg: default_msg.to_string(),
cursor_position: 0,
input_type: InputType::Multiline,
should_use_rect: false,
current_area: Cell::new(Rect::default()),
}
}
Expand Down Expand Up @@ -241,6 +243,10 @@ impl TextInputComponent {
f.render_widget(w, rect);
}
}

pub fn set_should_use_rect(&mut self, b: bool) {
self.should_use_rect = b;
}
}

// merges last line of `txt` with first of `append` so we do not generate unneeded newlines
Expand All @@ -267,7 +273,7 @@ impl DrawableComponent for TextInputComponent {
fn draw<B: Backend>(
&self,
f: &mut Frame<B>,
_rect: Rect,
rect: Rect,
) -> Result<()> {
if self.visible {
let txt = if self.msg.is_empty() {
Expand All @@ -279,16 +285,21 @@ impl DrawableComponent for TextInputComponent {
self.get_draw_text()
};

let area = match self.input_type {
InputType::Multiline => {
let area = ui::centered_rect(60, 20, f.size());
ui::rect_inside(
Size::new(10, 3),
f.size().into(),
area,
)
let area = if self.should_use_rect {
rect
} else {
match self.input_type {
InputType::Multiline => {
let area =
ui::centered_rect(60, 20, f.size());
ui::rect_inside(
Size::new(10, 3),
f.size().into(),
area,
)
}
_ => ui::centered_rect_absolute(32, 3, f.size()),
}
_ => ui::centered_rect_absolute(32, 3, f.size()),
};

f.render_widget(Clear, area);
Expand Down
Loading