bugfix: watch hook begin at next call

This commit is contained in:
Cloud Wu
2015-02-12 14:34:52 +08:00
parent bd790cbdf1
commit 76ab48df3b

View File

@@ -114,8 +114,7 @@ function linehook(mode, line)
return return
end end
end end
-- Lua 5.3 report currentline seems wrong change_prompt(string.format("%s(%d)>",ctx.filename, line))
change_prompt(string.format("%s(%d)>",ctx.filename, line-1))
return true -- yield return true -- yield
end end
end end
@@ -124,14 +123,18 @@ local function add_watch_hook()
local co = coroutine.running() local co = coroutine.running()
local ctx = {} local ctx = {}
ctx_active[co] = ctx ctx_active[co] = ctx
local level = 3 local level = 1
sethook(function() sethook(function(mode)
level = level - 1 if mode == "return" then
if level == 0 then level = level - 1
ctx.needupdate = true else
sethook(linehook, "crl") level = level + 1
if level == 0 then
ctx.needupdate = true
sethook(linehook, "crl")
end
end end
end, "r") end, "cr")
end end
local function watch_proto(protoname, cond) local function watch_proto(protoname, cond)