Added Doc:on_close() for plugins
This commit is contained in:
parent
bd02095a13
commit
1a51dad23c
|
@ -1,5 +1,6 @@
|
||||||
local Object = require "core.object"
|
local Object = require "core.object"
|
||||||
local Highlighter = require "core.doc.highlighter"
|
local Highlighter = require "core.doc.highlighter"
|
||||||
|
local core = require "core"
|
||||||
local syntax = require "core.syntax"
|
local syntax = require "core.syntax"
|
||||||
local config = require "core.config"
|
local config = require "core.config"
|
||||||
local common = require "core.common"
|
local common = require "core.common"
|
||||||
|
@ -493,5 +494,10 @@ end
|
||||||
function Doc:on_text_change(type)
|
function Doc:on_text_change(type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- For plugins to get notified when a document is closed
|
||||||
|
function Doc:on_close()
|
||||||
|
core.log_quiet("Closed doc \"%s\"", self:get_name())
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return Doc
|
return Doc
|
||||||
|
|
|
@ -972,7 +972,7 @@ function core.step()
|
||||||
local doc = core.docs[i]
|
local doc = core.docs[i]
|
||||||
if #core.get_views_referencing_doc(doc) == 0 then
|
if #core.get_views_referencing_doc(doc) == 0 then
|
||||||
table.remove(core.docs, i)
|
table.remove(core.docs, i)
|
||||||
core.log_quiet("Closed doc \"%s\"", doc:get_name())
|
doc:on_close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue