todos and fix unindent

fixed behaviour where caret would move even when the un-indentation did not
do anything, now before modifying caret position check wether the file changed
master
Alessandro Mauri 3 years ago
parent fe9ab1c922
commit fe3f1211ad
  1. 10
      TODO
  2. 5
      data/core/commands/doc.lua
  3. 2
      data/core/doc/init.lua

10
TODO

@ -16,12 +16,18 @@
[ ] console: accept input [ ] console: accept input
[ ] doc: detect file changes with hash [ ] doc: detect file changes with hash
[ ] add a cross to close tab [ ] add a cross to close tab
[ ] add context menu to various things
[ ] document and selection context menu
[ ] treeview context menu
[ ] tab context menu for close duplicate etc
[ ] prevent overscrolling on treeview [ ] prevent overscrolling on treeview
[x] user config file and/or init.lua [x] user config file and/or init.lua
[x] change tmp directory to somewhere in /tmp [x] change tmp directory to somewhere in /tmp
[x] save project directory and restore on reopening [x] save project directory and restore on reopening
[ ] optimize dir tree taking too long to load on big folders [ ] optimize dir tree taking too long to load on big folders
[ ] SDL: optimize drawing operations [ ] SDL: optimize drawing operations
[ ] implement render queue for each frame and render in batch, this
should save some time and improve cache locality
[ ] syntax: do not reload syntax on every draw event [ ] syntax: do not reload syntax on every draw event
[ ] go in background when launching from terminal [ ] go in background when launching from terminal
[ ] some key bindings: [ ] some key bindings:
@ -37,8 +43,8 @@
[x] ctrl+n -> next_find [x] ctrl+n -> next_find
[x] ctrl+shift+n -> prev_find [x] ctrl+shift+n -> prev_find
[x] f3 -> new file [x] f3 -> new file
[ ] selected + tab == indent up [x] selected + tab == indent up
[ ] selected +shift+tab == indent down [x] selected +shift+tab == indent down
[x] change alt+<number> to ctrl+<number> [x] change alt+<number> to ctrl+<number>
[ ] add multi cursor system [ ] add multi cursor system
[ ] add binding to open up a cheatsheet of keybinding, with a [ ] add binding to open up a cheatsheet of keybinding, with a

@ -38,6 +38,7 @@ end
local function remove_from_start_of_selected_lines(text, skip_empty) local function remove_from_start_of_selected_lines(text, skip_empty)
local line1, col1, line2, col2, swap = doc():get_selection(true) local line1, col1, line2, col2, swap = doc():get_selection(true)
local stat_before = doc():get_change_id()
for line = line1, line2 do for line = line1, line2 do
local line_text = doc().lines[line] local line_text = doc().lines[line]
if line_text:sub(1, #text) == text if line_text:sub(1, #text) == text
@ -46,7 +47,9 @@ local function remove_from_start_of_selected_lines(text, skip_empty)
doc():remove(line, 1, line, #text + 1) doc():remove(line, 1, line, #text + 1)
end end
end end
if doc():get_change_id() ~= stat_before then
doc():set_selection(line1, col1 - #text, line2, col2 - #text, swap) doc():set_selection(line1, col1 - #text, line2, col2 - #text, swap)
end
end end
@ -181,7 +184,7 @@ local commands = {
["doc:unindent"] = function() ["doc:unindent"] = function()
local text = get_indent_string() local text = get_indent_string()
remove_from_start_of_selected_lines(text) remove_from_start_of_selected_lines(text, true)
end, end,
["doc:duplicate-lines"] = function() ["doc:duplicate-lines"] = function()

@ -65,6 +65,8 @@ function Doc:reset_syntax()
end end
-- TODO: implement a new table containing hashes, re-hash at every consistent
-- change and use the hash difference as check for dirty
function Doc:load(filename) function Doc:load(filename)
local fp = assert( io.open(filename, "rb") ) local fp = assert( io.open(filename, "rb") )
self:reset() self:reset()

Loading…
Cancel
Save