Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: clear key mapping; default to <C-l> #739

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

teocns
Copy link
Contributor

@teocns teocns commented Oct 21, 2024

Uses Config.windows.ask.start_insert to determine whether to go insert mode after clearing. Is this something we want, or should we create a separate config?

Clear mapping is set on mappings.sidebar.clear, but feel free to suggest a better one if this doesn't fit the sidebar context

Uses Config.windows.ask.start_insert to determine whether to go insert
mode after clearing
@teocns
Copy link
Contributor Author

teocns commented Oct 21, 2024

@yetone have my back with the linter please

@yetone
Copy link
Owner

yetone commented Oct 21, 2024

‌‌‌‌Should we confirm before clearing? Because in my opinion, deletion is always the most dangerous operation.

@teocns
Copy link
Contributor Author

teocns commented Oct 21, 2024

<C-l> is a pretty standard clear command. Perhaps one doesn't just randomly press that. Usually no confirmation is prompted (hence the "shortcut" name).

Tip

CopilotChat.nvim behaves the same way

Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't agree with this. This should be done manually instead of this.

delete is dangerous, share same sentiment with yetone (but it seems like you are saving it to history before deleting it, which seems a bit misleading)

I'm fine doing this through a cmd or sth

@teocns
Copy link
Contributor Author

teocns commented Oct 24, 2024

How about double <C-l> <C-l> + warning at first key stroke?
I understand deleting is dangerous and might require some sort of confirmation, though I wouldn't see the point in having an extra confirmation step such as pressing Y: it'd consume as much time as typing /clear, and Y is also a painful key to reach

but it seems like you are saving it to history before deleting it

how weird - I'll take a look

@aarnphm
Copy link
Collaborator

aarnphm commented Oct 24, 2024

L1245

@teocns
Copy link
Contributor Author

teocns commented Oct 26, 2024

Right, I just replicated the same behavior of /clear buying a safe ticket to consistency in behaviors:

clear = function(args, cb)
local chat_history = Path.history.load(self.code.bufnr)
if next(chat_history) ~= nil then
chat_history = {}
Path.history.save(self.code.bufnr, chat_history)
self:update_content("Chat history cleared", { focus = false, scroll = false })
vim.defer_fn(function()
self:close()
if cb then cb(args) end
end, 1000)

You might wanna look at the blame history.

@teocns
Copy link
Contributor Author

teocns commented Oct 26, 2024

Added double keystroke for <C-l> + warning showing to press again before deleting

4778e1e

This behavior lines up with my expectation, but if you don't vision it merged feel free to leave it aside or modify it at will

yetone and others added 2 commits November 24, 2024 19:38
…ing chat history

fix(lua/avante/sidebar.lua): improve handling of warning shown flag to
prevent accidental clearing of chat history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants