From fe3f1211add0933d6956b5046c34634bad194e16 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Tue, 6 Jul 2021 22:06:51 +0200 Subject: [PATCH] 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 --- TODO | 10 ++++++++-- data/core/commands/doc.lua | 7 +++++-- data/core/doc/init.lua | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index e866dad..b6362b1 100644 --- a/TODO +++ b/TODO @@ -16,12 +16,18 @@ [ ] console: accept input [ ] doc: detect file changes with hash [ ] 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 [x] user config file and/or init.lua [x] change tmp directory to somewhere in /tmp [x] save project directory and restore on reopening [ ] optimize dir tree taking too long to load on big folders [ ] 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 [ ] go in background when launching from terminal [ ] some key bindings: @@ -37,8 +43,8 @@ [x] ctrl+n -> next_find [x] ctrl+shift+n -> prev_find [x] f3 -> new file - [ ] selected + tab == indent up - [ ] selected +shift+tab == indent down + [x] selected + tab == indent up + [x] selected +shift+tab == indent down [x] change alt+ to ctrl+ [ ] add multi cursor system [ ] add binding to open up a cheatsheet of keybinding, with a diff --git a/data/core/commands/doc.lua b/data/core/commands/doc.lua index 0a4ee42..0687a18 100644 --- a/data/core/commands/doc.lua +++ b/data/core/commands/doc.lua @@ -38,6 +38,7 @@ end local function remove_from_start_of_selected_lines(text, skip_empty) local line1, col1, line2, col2, swap = doc():get_selection(true) + local stat_before = doc():get_change_id() for line = line1, line2 do local line_text = doc().lines[line] 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) end end - doc():set_selection(line1, col1 - #text, line2, col2 - #text, swap) + if doc():get_change_id() ~= stat_before then + doc():set_selection(line1, col1 - #text, line2, col2 - #text, swap) + end end @@ -181,7 +184,7 @@ local commands = { ["doc:unindent"] = function() local text = get_indent_string() - remove_from_start_of_selected_lines(text) + remove_from_start_of_selected_lines(text, true) end, ["doc:duplicate-lines"] = function() diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index 83b5fc0..8ee3d49 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -65,6 +65,8 @@ function Doc:reset_syntax() 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) local fp = assert( io.open(filename, "rb") ) self:reset()