File tree 1 file changed +19
-10
lines changed
1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -41,23 +41,32 @@ func (t *tracker) reindex(tree *tree, height int) {
41
41
t .doReindex (tree )
42
42
t .selector .reindex (t .nodes )
43
43
44
- // When pug first starts up, for the user's convenience we want the cursor
45
- // to be on the first module. Because modules are added asynchronously, a
46
- // semaphore detects whether the cursor has been set to the first module, to
47
- // ensure this is only done once.
48
- if ! t .initialized {
44
+ placeCursorOnFirstModule := func () bool {
49
45
for i , n := range t .nodes {
50
46
if _ , ok := n .(moduleNode ); ok {
51
47
t .cursorNode = t .nodes [i ]
52
48
t .cursorIndex = i
53
- t .initialized = true
54
- break
49
+ return true
55
50
}
56
51
}
52
+ // If no modules found then set cursor on first node
53
+ if t .cursorIndex < 0 {
54
+ t .cursorNode = t .nodes [0 ]
55
+ t .cursorIndex = 0
56
+ }
57
+ return false
57
58
}
58
- if t .cursorIndex < 0 {
59
- t .cursorNode = t .nodes [0 ]
60
- t .cursorIndex = 0
59
+
60
+ // When pug first starts up, for the user's convenience we want the cursor
61
+ // to be on the first module. Because modules are added asynchronously, a
62
+ // semaphore detects whether the cursor has been set to the first module, to
63
+ // ensure this is only done once.
64
+ if ! t .initialized {
65
+ if placeCursorOnFirstModule () {
66
+ t .initialized = true
67
+ }
68
+ } else if t .cursorIndex < 0 {
69
+ placeCursorOnFirstModule ()
61
70
}
62
71
t .setStart (height )
63
72
}
You can’t perform that action at this time.
0 commit comments