fixed broken Doc:save monkeypatch
This commit is contained in:
parent
4e93eabbac
commit
ea5e9b0ce5
|
@ -47,7 +47,7 @@ local function save(filename)
|
|||
core.log("Saved \"%s\"", saved_filename)
|
||||
end
|
||||
|
||||
-- returns the size of the original indent, and the indent
|
||||
-- returns the size of the original indent, and the indent
|
||||
-- in your config format, rounded either up or down
|
||||
local function get_line_indent(line, rnd_up)
|
||||
local _, e = line:find("^[ \t]+")
|
||||
|
@ -58,18 +58,18 @@ local function get_line_indent(line, rnd_up)
|
|||
else
|
||||
local indent = e and line:sub(1, e):gsub("\t", soft_tab) or ""
|
||||
local number = #indent / #soft_tab
|
||||
return e, indent:sub(1,
|
||||
return e, indent:sub(1,
|
||||
(rnd_up and math.ceil(number) or math.floor(number))*#soft_tab)
|
||||
end
|
||||
end
|
||||
|
||||
-- un/indents text; behaviour varies based on selection and un/indent.
|
||||
-- * if there's a selection, it will stay static around the
|
||||
-- * if there's a selection, it will stay static around the
|
||||
-- text for both indenting and unindenting.
|
||||
-- * if you are in the beginning whitespace of a line, and are indenting, the
|
||||
-- * if you are in the beginning whitespace of a line, and are indenting, the
|
||||
-- cursor will insert the exactly appropriate amount of spaces, and jump the
|
||||
-- cursor to the beginning of first non whitespace characters
|
||||
-- * if you are not in the beginning whitespace of a line, and you indent, it
|
||||
-- * if you are not in the beginning whitespace of a line, and you indent, it
|
||||
-- inserts the appropriate whitespace, as if you typed them normally.
|
||||
-- * if you are unindenting, the cursor will jump to the start of the line,
|
||||
-- and remove the appropriate amount of spaces (or a tab).
|
||||
|
@ -83,7 +83,7 @@ local function indent_text(unindent)
|
|||
for line = line1, line2 do
|
||||
local e, rnded = get_line_indent(doc().lines[line], unindent)
|
||||
doc():remove(line, 1, line, (e or 0) + 1)
|
||||
doc():insert(line, 1,
|
||||
doc():insert(line, 1,
|
||||
unindent and rnded:sub(1, #rnded - #text) or rnded .. text)
|
||||
end
|
||||
l1d, l2d = #doc().lines[line1] - l1d, #doc().lines[line2] - l2d
|
||||
|
|
|
@ -415,8 +415,8 @@ local function reload_on_user_module_save()
|
|||
-- auto-realod style when user's module is saved by overriding Doc:Save()
|
||||
local doc_save = Doc.save
|
||||
local user_filename = system.absolute_path(USERDIR .. PATHSEP .. "init.lua")
|
||||
function Doc:save(filename)
|
||||
doc_save(self)
|
||||
function Doc:save(filename, abs_filename)
|
||||
doc_save(self, filename, abs_filename)
|
||||
if self.abs_filename == user_filename then
|
||||
core.reload_module("core.style")
|
||||
core.load_user_directory()
|
||||
|
|
Loading…
Reference in New Issue