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: change esc to act like cancel for change prompt #33

Merged
merged 5 commits into from
Dec 4, 2022

Conversation

chanced
Copy link
Contributor

@chanced chanced commented Dec 2, 2022

This PR changes the behavior of pressing escape when prompted for changes. Currently, the behavior of escape acts like ignore, allowing the buffer to be closed. This changes the behavior so that it acts like cancel.

Resolves #32

It's a quick hack and may be considered somewhat of a breaking change if folks were accustomed to pressing any key to close.

@chanced
Copy link
Contributor Author

chanced commented Dec 2, 2022

edit accidentally selected the wrong issue. It should be #32

@@ -40,7 +40,7 @@ local function buf_kill(range, force, wipeout)

-- If force is disabled, check for modified buffers in range.
if not force then
for bufnr, _ in pairs(target_buffers) do
for bufnr, buf in pairs(target_buffers) do
Copy link
Owner

Choose a reason for hiding this comment

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

why did you make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, that was an artifact from a different approach I was taking. I just forgot to remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

target_buffers[bufnr] = nil
end

-- Clear message area.
cmd.echo('""')
cmd.redraw()
end

Copy link
Owner

Choose a reason for hiding this comment

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

Remove this unnecessary newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -55,14 +55,15 @@ local function buf_kill(range, force, wipeout)

if choice == 's' or choice == 'S' then -- Save changes to the buffer.
api.nvim_buf_call(bufnr, function() cmd.write() end)
elseif choice == 'c' or choice == 'C' then -- Cancel, remove buffer from targets.
elseif choice ~= 'i' and choice ~= 'I' then -- If not ignored, do not close
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
elseif choice ~= 'i' and choice ~= 'I' then -- If not ignored, do not close
elseif choice ~= 'i' and choice ~= 'I' then -- If not ignored, remove buffer from targets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

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.

[Feature] Allow for configurability of pressing esc when prompted regarding changes after bufdelete(0, false)
2 participants