# Add "Add to \.gitignore" action in project_panel \(\#47377\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/e4e656fb42a01cd8db7aea53c48ae0f38377db57)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: e4e656fb42a01cd8db7aea53c48ae0f38377db57

Requested commit: e4e656fb42a01cd8db7aea53c48ae0f38377db57

Commit: e4e656fb42a01cd8db7aea53c48ae0f38377db57

Tree: f080a783cf9b428b0235fdfc67c7f50889be00bc

Author: Korbin de Man

Committer: GitHub

## Message

```
Add  "Add to .gitignore" action in project_panel (#47377)

This PR adds a "Add to .gitignore" action to the project panel's
right-click context menu. Similar to the "Restore File" action that I
previously added, I frequently find myself wanting this in the project
panel.

<img width="380" height="391" alt="image"
src="https://github.com/user-attachments/assets/e4438fbe-b070-40c8-9e57-84b003fa5c15"
/>

With the restore file option:
<img width="382" height="408" alt="image"
src="https://github.com/user-attachments/assets/84425de8-04e5-4969-8991-edc46e6420dc"
/>

Notes:
- **Implementation**: The `add_to_gitignore` function is essentially
copy-pasted from `git_panel.rs`.

- **Error handling**: Added toast notification on error, which is
consistent with `restore_file` in project_panel and `perform_checkout`
in git_panel.
Note that `add_to_gitignore` in git_panel does NOT show a toast (just
uses `detach_and_log_err`). I don't know if this is on purpose.
To follow up, I can either: match the project_panel implementation to
the git_panel one (no toast), or update the git_panel implementation to
also show a toast on error.

- **Menu grouping**: Previously "Restore File" and "View File History"
were in separate sections, but both relate to git. With this third git
action, I grouped all three together under a single separator (see
screenshot).
We could also keep "View File History" separate and only group "Restore
File" + "Add to .gitignore" together (both modify the working tree state
in some way), if we don't want to alter the existing UI too much.

Release Notes:

- Added "Add to .gitignore" option to the project panel context menu for
files in git repositories.

---------

Co-authored-by: Chris Biscardi <chris@christopherbiscardi.com>
```

## Parents

- [debf4c99881da48b81d44193fb8e7863806617d4](https://git.cafe/gitcafe/zed/commit/debf4c99881da48b81d44193fb8e7863806617d4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/e4e656fb42a01cd8db7aea53c48ae0f38377db57?format=markdown)
