about summary refs log tree commit diff stats
path: root/shell/sandbox.mu
diff options
context:
space:
mode:
Diffstat (limited to 'shell/sandbox.mu')
-rw-r--r--shell/sandbox.mu19
1 files changed, 13 insertions, 6 deletions
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 5cc75a0f..09f6f4d1 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -659,7 +659,9 @@ fn run _in-ah: (addr handle gap-buffer), out: (addr stream byte), globals: (addr
 #?   set-cursor-position 0/screen, 0 0
 #?   turn-on-debug-print
   debug-print "^", 4/fg, 0/bg
-  evaluate read-result-ah, eval-result-ah, *nil-ah, globals, trace, screen-cell, keyboard-cell, 0/definitions-created, 1/call-number
+  var definitions-created-storage: (stream int 0x10)
+  var definitions-created/ecx: (addr stream int) <- address definitions-created-storage
+  evaluate read-result-ah, eval-result-ah, *nil-ah, globals, trace, screen-cell, keyboard-cell, definitions-created, 1/call-number
   debug-print "$", 4/fg, 0/bg
   var error?/eax: boolean <- has-errors? trace
   {
@@ -671,14 +673,19 @@ fn run _in-ah: (addr handle gap-buffer), out: (addr stream byte), globals: (addr
   print-cell eval-result-ah, out, trace
   # refresh various rendering caches
   mark-lines-dirty trace
-  # if there was no error and the read-result starts with "set" or "def", save
-  # the gap buffer in the modified global, then create a new one for the next
-  # command.
-  var stashed?/eax: boolean <- maybe-stash-gap-buffer-to-global globals, read-result-ah, _in-ah
+  # If any definitions were created or modified in the process, link this gap
+  # buffer to them.
+  # TODO: detect and create UI for conflicts.
+  stash-gap-buffer-to-globals globals, definitions-created, _in-ah
   # if necessary, initialize a new gap-buffer in 'gap'
   {
-    compare stashed?, 0/false
+    compare globals, 0
     break-if-=
+    rewind-stream definitions-created
+    var no-definitions?/eax: boolean <- stream-empty? definitions-created
+    compare no-definitions?, 0/false
+    break-if-!=
+    # some definitions were created; clear the gap buffer
     var in-ah/edi: (addr handle gap-buffer) <- copy _in-ah
     var in/eax: (addr gap-buffer) <- lookup *in-ah
     var capacity/ecx: int <- gap-buffer-capacity in
3.subx.html?h=hlt&id=c8998b51e1995c307ddf831bff65309d57c25386'>c8998b51 ^
c83dca9c ^
c8998b51 ^




86351aaf ^
c8998b51 ^



6070c23e ^
c8998b51 ^
86351aaf ^
cea97b7b ^

6070c23e ^
c8998b51 ^


86351aaf ^
c8998b51 ^


86351aaf ^
c8998b51 ^


86351aaf ^































c83dca9c ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143