Describe the bug
I am trying to open the E2 editor via a script for automating a chip upload. However, I noticed the following error when the Editor mode for syntax highlighting is disabled:
[wiremod_git] addons/wiremod_git/lua/wire/client/text_editor/texteditor.lua:2143: bad argument #1 to 'pairs' (table expected, got nil)
1. pairs - [C]:-1
2. ac - addons/wiremod_git/lua/wire/client/text_editor/texteditor.lua:2143
3. AC_Check - addons/wiremod_git/lua/wire/client/text_editor/texteditor.lua:2488
4. unknown - addons/wiremod_git/lua/wire/client/text_editor/texteditor.lua:2469
Timer Failed! [E2_AC_Check][@addons/wiremod_git/lua/wire/client/text_editor/texteditor.lua (line 2468)]
How to reproduce the bug
As I open a file via Luapad, imagine you have some E2 code file: data/luapad/test.txt. Load the file via the following because I do not need syntax highlighting:
if(not IsValid(wire_expression2_editor)) then -- Expression 2 editor is not present
wire_expression2_editor = vgui.Create("Expression2EditorFrame")
end -- Expression 2 editor is available, then use it to display file contents
if(not IsValid(wire_expression2_editor)) then
Error("Frame invalid!"); return
end -- Setup the editor. Omit the last parameter to disable highlighting
wire_expression2_editor:Setup("Wiremod editor", "luapad/")
-- The highlighting style defaults to "Default" ( Neither E2 nor zCPU)
-- Load the file
local fF = "luapad/test.txt"
-- Do some logic
if(file.Exists(fF,"DATA")) then -- We cave category for the tracks
wire_expression2_editor:Open(fF, nil, false) -- Let E2 handle file paths
-- If the content is forced, the save triggers `save as`
else
Error("File missing!")
end
Then click the first row to trigger the highlighting as a result, FindKeywords fails because there is no Default syntax
function Editor:Setup(nTitle, nLocation, nEditorType)
self.Title = nTitle
self.Location = nLocation
self.EditorType = nEditorType
self.C.Browser:Setup(nLocation)
self:SetEditorMode(nEditorType or "Default")
local editorMode = WireTextEditor.Modes[self:GetEditorMode() or "Default"]
-- Later used in the syntax function
local function FindKeywords(self, word)
local suggestions, count = {}, 0
for kw in pairs(self.CurrentMode.Keywords) do
if kw:sub(1, #word) == word then
count = count + 1
local function get() return kw end
suggestions[count] = {
nice_str = get, str = get, data = { kw },
replacement = function(self, editor)
return kw, #kw
end,
selected_color = AC_COLOR_KEYWORD_SELECTED,
color = AC_COLOR_KEYWORD,
description = function() return "The keyword " .. kw end
}
end
end
return suggestions
end
Describe the bug
I am trying to open the E2 editor via a script for automating a chip upload. However, I noticed the following error when the Editor mode for syntax highlighting is disabled:
How to reproduce the bug
As I open a file via
Luapad, imagine you have some E2 code file:data/luapad/test.txt. Load the file via the following because I do not need syntax highlighting:Then click the first row to trigger the highlighting as a result,
FindKeywordsfails because there is noDefaultsyntax