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

Cut command is very slowly on Windows Terminal #3280

Open
og900aero opened this issue May 2, 2024 · 4 comments
Open

Cut command is very slowly on Windows Terminal #3280

og900aero opened this issue May 2, 2024 · 4 comments

Comments

@og900aero
Copy link

I use micro in Windows 10 with Windows terminal preview 1.20.10822.0
When I open file for edit in micro, then I hold down the CTRL+K key, it doesn't continuously delete the lines, but does nothing. When I release it, it deletes one row. If I use the nano program, there is no such problem.

I tried with the following version:

$micro --version
Version: 2.0.13
Commit hash: 68d88b5
Compiled on October 21, 2023

$ micro --version
Version: 2.0.14-dev.155
Commit hash: 5510317
Compiled on April 23, 2024

bindings.json:

{
    "\u001b[2J": "SelectToStartOfLine",
    "\u001b[K": "SelectToEndOfLine",
    "\u001b[P": "Delete",
    "Alt-/": "lua:comment.comment",
    "Alt-3": "lua:comment.comment",
    "Alt-Left": "PreviousTab",
    "Alt-Right": "NextTab",
    "Alt-g": "None",
    "Alt-w": "FindNext",
    "Ctrl-d": "DuplicateLine",
    "Ctrl-k": "Cut",
    "Ctrl-r": "command-edit:replaceall ",
    "Ctrl-s": "Save",
    "Ctrl-w": "Find",
    "Ctrl-x": "Quit",
    "CtrlUnderscore": "lua:comment.comment"
}
settings.json:

{
    "*.json": {
        "commenttype": "/* %s */"
    },
    "*.jsonc": {
        "commenttype": "/* %s */"
    },
    "*Xresources*": {
        "commenttype": "! %s"
    },
    "autoclose": false,
    "autosu": true,
    "backup": false,
    "clipboard": "terminal",
    "hlsearch": true,
    "softwrap": true
}
@Gavin-Holt
Copy link

Gavin-Holt commented May 5, 2024

Hi

In my Windows setup I wanted to delete the current line or all partially selected lines (my version of wordstar yank block ^KY):

  1. I bind CTRL+Y as follows in bindings.json
    "CtrlY": "lua:initlua.delsel,SelectLine,Delete",
  1. From my init.lua file:
function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
    if Current.Cursor:HasSelection(Current) then
        Current.Cursor:DeleteSelection()
    end
end
  1. This repeats if I hold down CTRL+Y, it works on Windows console and Windows terminal.

Kind Regards Gavin Holt

@og900aero
Copy link
Author

function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
    if Current.Cursor:HasSelection(Current) then
        Current.Cursor:DeleteSelection()
    end
end

I paste the following line in the bindings.json:

"Ctrl-k": "lua:initlua.delsel,SelectLine,Delete",

Then I create ~/.config/micro/init.lua file, and insert the following rows:

function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
    if Current.Cursor:HasSelection(Current) then
        Current.Cursor:DeleteSelection()
    end
end

Now , when I press ctrl+k, the the following error message appear:

init:3: invalid number of function arguments (1 expected, got 2)
stack traceback:
        [G]: in function 'HasSelection'
        init:3: in main chunk
        [G]: ?

Press enter to continue

@Gavin-Holt
Copy link

Hi

Sorry try:

function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
    if Current.Cursor:HasSelection() then
        Current.Cursor:DeleteSelection()
    end
end

Kind Regards Gavin Holt

@og900aero
Copy link
Author

Hi

Sorry try:

function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
    if Current.Cursor:HasSelection() then
        Current.Cursor:DeleteSelection()
    end
end

Kind Regards Gavin Holt

Thx. Working great.

But it wouldn't be bad if the deletion would also work with the Cut command when pressed for a long time, as in the case of a Linux terminals.

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

No branches or pull requests

2 participants