aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/editing.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2016-04-05 20:49:23 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2016-04-05 20:49:23 -0400
commit47d8b1a2beba8a737c325fcfe95050f399fdeaf9 (patch)
tree9c2858dfb426b8b219993de72aaaab8db69f0eef /modules/textadept/editing.lua
parentdd67ffe17bc8b1a472124a72783f557c61473fef (diff)
downloadtextadept-47d8b1a2beba8a737c325fcfe95050f399fdeaf9.tar.gz
textadept-47d8b1a2beba8a737c325fcfe95050f399fdeaf9.zip
Fixed indentation conversion; modules/textadept/editing.lua
Use mixture of tabs and spaces when necessary in order to preserve indentation amount.
Diffstat (limited to 'modules/textadept/editing.lua')
-rw-r--r--modules/textadept/editing.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index d024808b..00f8edcb 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -441,7 +441,9 @@ function M.convert_indentation()
local current_indentation, new_indentation = buffer:text_range(s, e), nil
if buffer.use_tabs then
-- Need integer division and LuaJIT does not have // operator.
- new_indentation = string.rep('\t', math.floor(indent / buffer.tab_width))
+ local tabs = math.floor(indent / buffer.tab_width)
+ local spaces = math.fmod(indent, buffer.tab_width)
+ new_indentation = string.rep('\t', tabs)..string.rep(' ', spaces)
else
new_indentation = string.rep(' ', indent)
end