@@ -145,21 +145,6 @@ if CLIENT then
145
145
end
146
146
end
147
147
148
- function SF .Editor .getOpenFiles ()
149
- local files = {}
150
- for i = 1 , SF .Editor .editor :GetNumTabs () do
151
- local tab = SF .Editor .editor :GetTabContent (i )
152
- local path = tab .chosenfile
153
- if path and tab .GetCode then
154
- if SF .Editor .editor :ShouldReloadBeforeUpload () then
155
- SF .Editor .editor :ReloadTabs (false )
156
- end
157
- files [path :match (" starfall/(.+)" ) or path ] = tab :GetCode ()
158
- end
159
- end
160
- return files
161
- end
162
-
163
148
function SF .Editor .createEditor ()
164
149
local editor = vgui .Create (" StarfallEditorFrame" ) -- Should define own frame later
165
150
@@ -212,8 +197,21 @@ if CLIENT then
212
197
function SF .Editor .BuildIncludesTable (mainfile , success , err )
213
198
if not SF .Editor .initialized then SF .Editor .init () end
214
199
215
- local openfiles = SF .Editor .getOpenFiles ()
216
- if not (mainfile and (openfiles [mainfile ] or file .Exists (" starfall/" .. mainfile , " DATA" ))) then
200
+ local opentabs = {}
201
+ for i = 1 , SF .Editor .editor :GetNumTabs () do
202
+ local tab = SF .Editor .editor :GetTabContent (i )
203
+ local path = tab .chosenfile
204
+ if path and tab .GetCode then
205
+ if SF .Editor .editor :ShouldReloadBeforeUpload () then
206
+ SF .Editor .editor :ReloadTab (i , false )
207
+ end
208
+ opentabs [string.match (path , " starfall/(.+)" ) or path ] = tab
209
+ end
210
+ end
211
+
212
+ local openfiles = setmetatable ({},{__index = function (t ,k ) if opentabs [k ] then local r = opentabs [k ]:GetCode () t [k ]= r return r end end })
213
+
214
+ if not (mainfile and (opentabs [mainfile ] or file .Exists (" starfall/" .. mainfile , " DATA" ))) then
217
215
mainfile = SF .Editor .getOpenFile () or " main"
218
216
if # mainfile == 0 then err (" Invalid main file" ) return end
219
217
openfiles [mainfile ] = SF .Editor .getCode ()
0 commit comments