aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-04-17 09:42:05 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-04-17 09:42:05 -0400
commitf845f7623501efab57768cbd81843e4c163fe412 (patch)
treee82921b0b5e443d831c1110aff6d3a25ae3e6db3
parent7e593d0b0a01c64b723a134418c215ed3593021f (diff)
downloadtextadept-f845f7623501efab57768cbd81843e4c163fe412.tar.gz
textadept-f845f7623501efab57768cbd81843e4c163fe412.zip
Remove initial 'Untitled' buffer when necessary.
Thanks to Robert Gieseke.
-rw-r--r--core/file_io.lua9
-rw-r--r--modules/textadept/session.lua1
2 files changed, 10 insertions, 0 deletions
diff --git a/core/file_io.lua b/core/file_io.lua
index 14db3a7f..005d6042 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -377,3 +377,12 @@ local function update_modified_file()
end
textadept.events.add_handler('buffer_after_switch', update_modified_file)
textadept.events.add_handler('view_after_switch', update_modified_file)
+
+textadept.events.add_handler('file_opened',
+ function(utf8_filename) -- close initial 'Untitled' buffer
+ local b = textadept.buffers[1]
+ if #textadept.buffers == 2 and not (b.filename or b._type or b.dirty) then
+ view:goto_buffer(1, true)
+ buffer:close()
+ end
+ end)
diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua
index af3d1887..20b0c831 100644
--- a/modules/textadept/session.lua
+++ b/modules/textadept/session.lua
@@ -51,6 +51,7 @@ function load(filename)
else
textadept.new_buffer()
buffer._type = filename
+ textadept.events.handle('file_opened', filename)
end
-- Restore saved buffer selection and view.
local anchor = tonumber(anchor) or 0