Neil Hodgson, 29.04.2006 10:17:
Frank Wunderlich:
it seems that in new files (or if no lexer is activated) that
lua-Startup-Script is not active.
I have a script using OnChar to close Brackets. this works with every
lexer but not on new files.
is this a bug or feature?
function OnChar(x)
print(x)
end
File | New, start typing and you'll see some printing.
ok, i see the error must in this function:
function OnChar(c)
function char_at(p)
return string.char(editor.CharAt[p])
end
local toClose = { ['('] = ')', ['['] = ']', ['"'] = '"', ["'"] = "'" }
if (toClose[c] ~= nil) then
local pos = editor.CurrentPos
local nextchar=char_at(pos+1)
if ((nextchar == "\n") or (nextchar == "\r")) then
editor:ReplaceSel(toClose[c])
editor:SetSel(pos, pos)
end
end
return false
end
one case when brackets are not closed is when currentPos=lastchar so
pos+1 is invalid (i've tested for nil, but no change)
regards
frank
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest