aboutsummaryrefslogtreecommitdiff
path: root/data/core/commandview.lua
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2021-09-07 18:33:58 +0200
committerFrancesco <francesco.bbt@gmail.com>2021-09-09 15:42:16 +0200
commitb440a2258118c916dfec657c676befca53e108ac (patch)
tree7ad6ea18899bc9d5248ecf46eba4db8464089a07 /data/core/commandview.lua
parentfa8b3b33b180d265f472877a23fb8df9a9eca191 (diff)
downloadpragtical-b440a2258118c916dfec657c676befca53e108ac.tar.gz
pragtical-b440a2258118c916dfec657c676befca53e108ac.zip
Remeber initial user text for hidden suggestions
When using hidden suggestions remember the text user was typing when navigating suggestions. Ensure also that in the previously searched expressiosn we have no duplicate entries.
Diffstat (limited to 'data/core/commandview.lua')
-rw-r--r--data/core/commandview.lua26
1 files changed, 20 insertions, 6 deletions
diff --git a/data/core/commandview.lua b/data/core/commandview.lua
index 5ccb8d3a..b91f1394 100644
--- a/data/core/commandview.lua
+++ b/data/core/commandview.lua
@@ -89,14 +89,27 @@ end
function CommandView:move_suggestion_idx(dir)
- local current_suggestion = #self.suggestions > 0 and self.suggestions[self.suggestion_idx].text
- if self.show_suggestions or self:get_text() == current_suggestion then
+ if self.show_suggestions then
local n = self.suggestion_idx + dir
self.suggestion_idx = common.clamp(n, 1, #self.suggestions)
- end
- self:complete()
- self.last_change_id = self.doc:get_change_id()
- if not self.show_suggestions then
+ self:complete()
+ self.last_change_id = self.doc:get_change_id()
+ else
+ local current_suggestion = #self.suggestions > 0 and self.suggestions[self.suggestion_idx].text
+ local text = self:get_text()
+ if text == current_suggestion then
+ local n = self.suggestion_idx + dir
+ if n == 0 and self.save_suggestion then
+ self:set_text(self.save_suggestion)
+ else
+ self.suggestion_idx = common.clamp(n, 1, #self.suggestions)
+ self:complete()
+ end
+ else
+ self.save_suggestion = text
+ self:complete()
+ end
+ self.last_change_id = self.doc:get_change_id()
self.state.suggest(self:get_text())
end
end
@@ -147,6 +160,7 @@ function CommandView:exit(submitted, inexplicit)
self.suggestions = {}
if not submitted then cancel(not inexplicit) end
self.show_suggestions = true
+ self.save_suggestion = nil
end