@@ -2,6 +2,7 @@ package config
22
33import (
44 "os"
5+ "runtime"
56 "strings"
67)
78
@@ -55,8 +56,15 @@ func returnBool(a bool) func() bool { return (func() bool { return a }) }
5556// IF YOU ADD A PRESET TO THIS FUNCTION YOU MUST UPDATE THE `Supported presets` SECTION OF docs/Config.md
5657func getPreset (shell string , osConfig * OSConfig , guessDefaultEditor func () string ) * editPreset {
5758 var nvimRemoteEditTemplate , nvimRemoteEditAtLineTemplate , nvimRemoteOpenDirInEditorTemplate string
58- // By default fish doesn't have SHELL variable set, but it does have FISH_VERSION since Nov 2012.
59- if (strings .HasSuffix (shell , "fish" )) || (os .Getenv ("FISH_VERSION" ) != "" ) {
59+ // Windows requires PowerShell due to environment variable syntax and conditional logic.
60+ // We use Start-Process to launch separate PowerShell process because otherwise lazygit will keep waiting for PowerShell and won't process the quit key
61+ // See: https://github.com/jesseduffield/lazygit/issues/3467
62+ if runtime .GOOS == "windows" {
63+ nvimRemoteEditTemplate = `powershell -NoProfile -Command "if ($env:NVIM) { $cmd = 'nvim --server ' + $env:NVIM + ' --remote-send q; nvim --server ' + $env:NVIM + ' --remote-tab ''{{filename}}'''; Start-Process powershell -ArgumentList '-NoProfile','-Command',$cmd -WindowStyle Hidden } else { nvim -- '{{filename}}' }"`
64+ nvimRemoteEditAtLineTemplate = `powershell -NoProfile -Command "if ($env:NVIM) { $cmd = 'nvim --server ' + $env:NVIM + ' --remote-send q; nvim --server ' + $env:NVIM + ' --remote-tab ''{{filename}}''; nvim --server ' + $env:NVIM + ' --remote-send '':{{line}}<CR>'''; Start-Process powershell -ArgumentList '-NoProfile','-Command',$cmd -WindowStyle Hidden } else { nvim +{{line}} -- '{{filename}}' }"`
65+ nvimRemoteOpenDirInEditorTemplate = `powershell -NoProfile -Command "if ($env:NVIM) { $cmd = 'nvim --server ' + $env:NVIM + ' --remote-send q; nvim --server ' + $env:NVIM + ' --remote-tab ''{{dir}}'''; Start-Process powershell -ArgumentList '-NoProfile','-Command',$cmd -WindowStyle Hidden } else { nvim -- '{{dir}}' }"`
66+ } else if (strings .HasSuffix (shell , "fish" )) || (os .Getenv ("FISH_VERSION" ) != "" ) {
67+ // By default fish doesn't have SHELL variable set, but it does have FISH_VERSION since Nov 2012.
6068 nvimRemoteEditTemplate = `begin; if test -z "$NVIM"; nvim -- {{filename}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{filename}}; end; end`
6169 nvimRemoteEditAtLineTemplate = `begin; if test -z "$NVIM"; nvim +{{line}} -- {{filename}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{filename}}; nvim --server "$NVIM" --remote-send ":{{line}}<CR>"; end; end`
6270 nvimRemoteOpenDirInEditorTemplate = `begin; if test -z "$NVIM"; nvim -- {{dir}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{dir}}; end; end`
0 commit comments