Skip to content

Commit

Permalink
fixed: git commit list dialog: clicking DOWN/UP arrows jumps two rows…
Browse files Browse the repository at this point in the history
… at a time
  • Loading branch information
eranif committed Jan 11, 2023
1 parent 51f26ce commit 07edcec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Plugin/clScrolledPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ void clScrolledPanel::OnCharHook(wxKeyEvent& event)
wxKeyEvent keyDown = event;
keyDown.SetEventType(wxEVT_KEY_DOWN);
if(DoKeyDown(keyDown)) {
// event was handled. Stop processing it
event.Skip(false);
return;
}

// Always process the HOME/END buttons
// The following can be processed only once
event.Skip(false);
if(event.GetEventObject() == this) {
if(event.GetKeyCode() == WXK_HOME) {
ScrollRows(0, wxUP);
Expand All @@ -270,7 +273,13 @@ void clScrolledPanel::OnCharHook(wxKeyEvent& event)
ScrollRows(GetPageSize(), wxUP);
} else if(event.GetKeyCode() == WXK_PAGEDOWN) {
ScrollRows(GetPageSize(), wxDOWN);
} else {
// propogate the event (i.e. we did not handle it here)
event.Skip();
}
} else {
// propogate the event (i.e. we did not handle it here)
event.Skip();
}
}

Expand Down
9 changes: 7 additions & 2 deletions git/gitCommitListDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ GitCommitListDlg::GitCommitListDlg(wxWindow* parent, const wxString& workingDir,
{
Bind(wxEVT_ASYNC_PROCESS_OUTPUT, &GitCommitListDlg::OnProcessOutput, this);
Bind(wxEVT_ASYNC_PROCESS_TERMINATED, &GitCommitListDlg::OnProcessTerminated, this);
Bind(wxEVT_CHAR_HOOK, &GitCommitListDlg::OnCharHook, this);
// Bind(wxEVT_CHAR_HOOK, &GitCommitListDlg::OnCharHook, this);

LexerConf::Ptr_t lex = EditorConfigST::Get()->GetLexer("diff");
if(lex) {
Expand Down Expand Up @@ -182,10 +182,13 @@ void GitCommitListDlg::DoLoadCommits(const wxString& filter)
// hash @ subject @ author-name @ date
wxArrayString gitList = wxStringTokenize(m_commitList, wxT("\n"), wxTOKEN_STRTOK);
wxArrayString filters = wxStringTokenize(filter, " ");
wxVector<wxVariant> cols;
for(unsigned i = 0; i < gitList.GetCount(); ++i) {
wxArrayString gitCommit = ::wxStringTokenize(gitList[i], "@");
if(gitCommit.GetCount() >= 4) {
wxVector<wxVariant> cols;
cols.clear();
cols.reserve(4);

cols.push_back(gitCommit.Item(0));
cols.push_back(gitCommit.Item(1));
cols.push_back(gitCommit.Item(2));
Expand Down Expand Up @@ -267,6 +270,7 @@ wxString GitCommitListDlg::GetFilterString() const

void GitCommitListDlg::OnNext(wxCommandEvent& event)
{
wxUnusedVar(event);
m_skip += 100;
// Check the cache first
if(m_history.count(m_skip)) {
Expand All @@ -278,6 +282,7 @@ void GitCommitListDlg::OnNext(wxCommandEvent& event)

void GitCommitListDlg::OnPrevious(wxCommandEvent& event)
{
wxUnusedVar(event);
int skip = m_skip - 100;
if(m_history.count(skip)) {
m_skip -= 100;
Expand Down

0 comments on commit 07edcec

Please sign in to comment.