@@ -45,12 +45,15 @@ export const registerLockfilesWatcher = () => {
45
45
const lockfileChangeHandler = ( action : 'created' | 'changed' ) => async ( uri : vsc . Uri ) => {
46
46
if ( getExtensionSetting ( 'install.watchLockfilesGitCheckouts' ) ) {
47
47
recentLockfileChanges ??= [ ]
48
+ let finalCallback : ( ( ) => void ) | undefined
48
49
if ( ! Array . isArray ( recentLockfileChanges ) ) {
49
- recentLockfileChanges ( )
50
+ finalCallback = recentLockfileChanges
50
51
recentLockfileChanges = [ ]
51
52
}
52
53
53
54
recentLockfileChanges . push ( { action, uri } )
55
+ // do it in next loop when all (probably) lockfileChangeHandler callback are called
56
+ setTimeout ( ( ) => finalCallback ?.( ) )
54
57
setTimeout ( ( ) => {
55
58
recentLockfileChanges = null
56
59
// vscode git is slow
@@ -100,7 +103,12 @@ export const registerLockfilesWatcher = () => {
100
103
if ( commit === newCommit ) return
101
104
commit = newCommit
102
105
103
- if ( recentLockfileChanges && ! Array . isArray ( recentLockfileChanges ) ) recentLockfileChanges ( true )
106
+ if ( recentLockfileChanges && ! Array . isArray ( recentLockfileChanges ) ) {
107
+ // on some random checkouts on windows, repo.state.onDidChange gets called twice,
108
+ // so we cancel old and bind new
109
+ recentLockfileChanges ( true )
110
+ recentLockfileChanges = null
111
+ }
104
112
// eslint-disable-next-line curly
105
113
if ( recentLockfileChanges === null ) {
106
114
await new Promise < void > ( ( resolve , reject ) => {
0 commit comments