picocode-core 0.9.133 → 0.9.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/git.js +17 -0
package/package.json
CHANGED
package/src/git.js
CHANGED
|
@@ -48,6 +48,7 @@ export function createGitService({ onChange = () => {} } = {}) {
|
|
|
48
48
|
let gitDir = null
|
|
49
49
|
let epoch = 0
|
|
50
50
|
let watcher = null
|
|
51
|
+
let treeWatcher = null
|
|
51
52
|
let poll = null
|
|
52
53
|
let debounce = null
|
|
53
54
|
let child = null
|
|
@@ -58,6 +59,8 @@ export function createGitService({ onChange = () => {} } = {}) {
|
|
|
58
59
|
epoch += 1
|
|
59
60
|
watcher?.close()
|
|
60
61
|
watcher = null
|
|
62
|
+
treeWatcher?.close()
|
|
63
|
+
treeWatcher = null
|
|
61
64
|
if (poll) clearInterval(poll)
|
|
62
65
|
poll = null
|
|
63
66
|
if (debounce) clearTimeout(debounce)
|
|
@@ -85,6 +88,20 @@ export function createGitService({ onChange = () => {} } = {}) {
|
|
|
85
88
|
} catch {
|
|
86
89
|
watcher = null
|
|
87
90
|
}
|
|
91
|
+
// the working tree too, so an edit shows up right away rather than at
|
|
92
|
+
// the next poll. recursive watching rides on FSEvents on macOS; the
|
|
93
|
+
// refresh is debounced so a burst of writes costs one git call
|
|
94
|
+
try {
|
|
95
|
+
treeWatcher = watch(root, { recursive: true }, (_event, file) => {
|
|
96
|
+
if (epoch !== started) return
|
|
97
|
+
const name = String(file ?? '')
|
|
98
|
+
if (name === '.git' || name.startsWith('.git/') || name.includes('node_modules')) return
|
|
99
|
+
refresh()
|
|
100
|
+
})
|
|
101
|
+
treeWatcher.on('error', () => {})
|
|
102
|
+
} catch {
|
|
103
|
+
treeWatcher = null
|
|
104
|
+
}
|
|
88
105
|
poll = setInterval(run, POLL_MS)
|
|
89
106
|
poll.unref?.()
|
|
90
107
|
run()
|