helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.92k stars 2.43k forks source link

Git Gutter is not updated after a git commit #4994

Open mar-mei opened 1 year ago

mar-mei commented 1 year ago

Summary

The UI of the new Git Gutter is not updated at git changes, such as a:

git commit

Reproduction Steps

I tried this: 1. `hx` 2. Open a file with a git repo 3. Make some changes 4. Save file 5. Run: `git commit -am "my changes"` in a new terminal I expected this to happen: UI is updated Instead, this happened: Git diff remains unchanged Only after a hx `:reload` of the file the ui ist updated --- ![hx](https://user-images.githubusercontent.com/43099631/205452154-97dfa959-5629-4d79-9839-08a03f6ea7f0.gif) ### Helix log
~/.cache/helix/helix.log ``` please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines ```
### Platform Linux ### Terminal Emulator Kitty ### Helix Version helix 22.08.1 (bcdb475b)
kirawi commented 1 year ago

This is a limitation in order to keep the initial PR scoped, but you can manually update it via :reload.

pascalkuthe commented 1 year ago

As @kirawi pointed out this is an intentional limitation of the current implementation as implementation file watching is challenging (and also has some other prerequisites like caching git repos) and therefore was too much to bundle with the initial implementation. I will be writing a poper tracking issue for my plans in that regard soon and close this issue then

quantonganh commented 1 year ago

I've just come up with a workaround using WezTerm: https://github.com/helix-editor/helix/issues/2261#issuecomment-1648036567.

sidequestboy commented 1 year ago

Is it possible to get helix to automatically call reload-all when it gets focused in the same way that auto-save is triggered? It might be a reasonable temporary fix while file-watching is being worked on

quantonganh commented 1 year ago

@sidequestboy You can do that by introducing a new configuration option auto-reload-all (defaults to false). Afterward, you can make the reload_all function public, and call it here. However, the potential drawback is that it might trigger reload-all too frequently. Moreover, in my opinion, we should avoid reloading unsaved changes buffers, as discussed in https://github.com/helix-editor/helix/issues/5680.

H4ckint0sh commented 1 year ago

I have made a script to do this using "tmux" (set-hook).

tmux.conf

bind-key g run-shell -b helix-lazygit

helix-lazygit

#!/bin/bash

# Split horizontally and run lazygit 
tmux split-window -v -l 70% -c "#{pane_current_path}" lazygit

# run reload script on exit
tmux set-hook pane-exited "run-shell '$HOME/bin/helix-reload.sh'"

helix-reload.sh

#!/bin/bash

# Data to be listed
LIST_DATA="#{pane_index} #{pane_current_command}"

# Find pane id where helix is running
HELIX_PANE_INDEX=$(tmux list-panes -a -F "$LIST_DATA" | grep "hx" | awk '{print $1}')

# Send reload command if such a pane exists
if [ -n "$HELIX_PANE_INDEX" ]; then

  # change to helix pane
  tmux select-pane -t $HELIX_PANE_INDEX

  # Send ":" to start command input in Helix
  tmux send-keys ":"

  # Send the "reload-all" command to the pane that runs helix and simulate Enter
  tmux send-keys "reload-all" C-m

fi
ygabuev commented 12 months ago

As @kirawi pointed out this is an intentional limitation of the current implementation as implementation file watching is challenging (and also has some other prerequisites like caching git repos) and therefore was too much to bundle with the initial implementation. I will be writing a poper tracking issue for my plans in that regard soon and close this issue then

@kirawi Hello. Is there any progress outlining this issue in more general terms? I guess this might be helpful, maybe someone else would be willing to work on this issue given a proper outline.