-
Notifications
You must be signed in to change notification settings - Fork 93
feat(explorer): open_on_empty config option
#520
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
Open
tkr-sh
wants to merge
3
commits into
esmuellert:main
Choose a base branch
from
tkr-sh:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,12 +372,18 @@ local function handle_explorer(revision, revision2, global_opts, pathspec) | |
|
|
||
| -- Check if there are any changes (including conflicts) | ||
| local has_conflicts = status_result.conflicts and #status_result.conflicts > 0 | ||
| if #status_result.unstaged == 0 and #status_result.staged == 0 and not has_conflicts then | ||
| local is_empty = #status_result.unstaged == 0 | ||
| and #status_result.staged == 0 | ||
| and not has_conflicts | ||
| if is_empty and not config.options.explorer.open_on_empty then | ||
| vim.notify("No changes to show", vim.log.levels.INFO) | ||
| return | ||
| end | ||
|
|
||
| -- Create explorer view with empty diff panes initially | ||
| -- Create explorer view with empty diff panes initially. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be placed in a wrong location and please also make it 1-2 lines |
||
| -- When open_on_empty is true and is_empty, status_result still has its | ||
| -- (empty) unstaged/staged/conflicts arrays, so the explorer renders | ||
| -- empty groups rather than nil-ing out. | ||
|
|
||
| ---@type SessionConfig | ||
| local session_config = { | ||
|
|
@@ -486,7 +492,7 @@ local function handle_explorer_staged(revision, global_opts, pathspec) | |
| return | ||
| end | ||
|
|
||
| if #status_result.staged == 0 then | ||
| if #status_result.staged == 0 and not config.options.explorer.open_on_empty then | ||
| vim.notify("No staged changes to show", vim.log.levels.INFO) | ||
| return | ||
| end | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -628,6 +628,15 @@ function M.create(status_result, git_root, tabpage, width, base_revision, target | |
| -- Setup auto-refresh | ||
| refresh_module.setup_auto_refresh(explorer, tabpage) | ||
|
|
||
| -- Empty working tree (explorer.open_on_empty): the explorer opened with zero | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you compact the comments to 1-2 lines? |
||
| -- files. Render the welcome banner in the diff panes (instead of blank | ||
| -- scratch buffers) so the state is legible. This mirrors what a refresh | ||
| -- shows when the tree later becomes empty. should_show_welcome() also rejects | ||
| -- dir mode, so directory comparisons are unaffected. | ||
| if should_show_welcome(explorer) then | ||
| show_welcome_page(explorer) | ||
| end | ||
|
|
||
| -- Re-render on window resize for dynamic width | ||
| vim.api.nvim_create_autocmd("WinResized", { | ||
| callback = function() | ||
|
|
||
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
Oops, something went wrong.
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.
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'd like to remove the comment here since most of other lines don't have