Allow to go to stage view without Enter#1284
Closed
krobelus wants to merge 1 commit intojonas:masterfrom
Closed
Conversation
9a3fc36 to
14c6bb0
Compare
After selecting unstaged or staged changes in main or status view and pressing "c" to go to stage view, we fail with this error No stage content, press s to open the status view and choose file We can work around this by pressing Enter before "c". This extra key press is really not necessary because the intent is clear. Let's make view-stage (and view-diff) go to the stage view straight away. Note: "d" already worked this way but only in the main view, I'm not sure why. The implementation needs to differentiate between "stat headers" like "Changes to be committed" and status lines that actually contain a file. For stat headers we show all files so we must be careful not to include a file filter. For untracked files, we show a blob so there is no natural way of showing all untracked files. Keep the above behavior for the untracked stat header.
Collaborator
|
Thanks @krobelus, but that's quite a lot of changes. In the spirit of what jonas did for "d" in the main view, couldn't we do more simply diff --git a/src/main.c b/src/main.c
index 2401295b..05145955 100644
--- a/src/main.c
+++ b/src/main.c
@@ -568,6 +568,14 @@ main_request(struct view *view, enum request request, struct line *line)
open_diff_view(view, flags);
break;
+ case REQ_VIEW_STAGE:
+ if (line->type == LINE_STAT_UNSTAGED
+ || line->type == LINE_STAT_STAGED)
+ open_stage_view(view, NULL, line->type, flags);
+ else
+ return request;
+ break;
+
case REQ_REFRESH:
load_refs(true);
refresh_view(view);
diff --git a/src/status.c b/src/status.c
index 0855dc34..7b476550 100644
--- a/src/status.c
+++ b/src/status.c
@@ -752,6 +752,15 @@ status_request(struct view *view, enum request request, struct line *line)
view->env->ref[0] = 0;
return request;
+ case REQ_VIEW_STAGE:
+ if ((line->type == LINE_STAT_STAGED
+ || line->type == LINE_STAT_UNSTAGED
+ || line->type == LINE_STAT_UNTRACKED) && status && status->status)
+ open_stage_view(view, status, line->type, view_is_displayed(view) ? OPEN_SPLIT : OPEN_DEFAULT);
+ else
+ return request;
+ break;
+
case REQ_ENTER:
/* After returning the status view has been split to
* show the stage view. No further reloading is |
Contributor
Author
|
Interesting. This doesn't work when running |
Collaborator
|
Actually, in the status view, the result is better with just: diff --git a/src/status.c b/src/status.c
index dd8c2afa..c9cfb684 100644
--- a/src/status.c
+++ b/src/status.c
@@ -756,6 +756,7 @@ status_request(struct view *view, enum request request, struct line *line)
view->env->ref[0] = 0;
return request;
+ case REQ_VIEW_STAGE:
case REQ_ENTER:
/* After returning the status view has been split to
* show the stage view. No further reloading is |
Contributor
Author
|
Thanks, that works as expected. I had forgotten to test it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After selecting unstaged or staged changes in main or status view
and pressing "c" to go to stage view, we fail with this error
We can work around this by pressing Enter before "c". This extra key
press is really not necessary because the intent is clear. Let's make
view-stage (and view-diff) go to the stage view straight away.
Note: "d" already worked this way but only in the main view, I'm not
sure why.
The implementation needs to differentiate between "stat headers"
like "Changes to be committed" and status lines that actually contain
a file. For stat headers we show all files so we must be careful not
to include a file filter.
For untracked files, we show a blob so there is no natural way of
showing all untracked files. Keep the above behavior for the untracked
stat header.