helix icon indicating copy to clipboard operation
helix copied to clipboard

Git Gutter is not updated after a git commit

Open mar-mei opened this issue 2 years ago • 2 comments
trafficstars

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

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)

mar-mei avatar Dec 03 '22 16:12 mar-mei

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

kirawi avatar Dec 03 '22 17:12 kirawi

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

pascalkuthe avatar Dec 03 '22 21:12 pascalkuthe

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

quantonganh avatar Jul 24 '23 14:07 quantonganh

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

sidequestboy avatar Aug 23 '23 21:08 sidequestboy

@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.

quantonganh avatar Aug 25 '23 02:08 quantonganh

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

H4ckint0sh avatar Aug 31 '23 06:08 H4ckint0sh

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.

ygabuev avatar Sep 25 '23 07:09 ygabuev