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

cursor keys not working #1

Closed
fishman opened this issue Mar 29, 2010 · 10 comments
Closed

cursor keys not working #1

fishman opened this issue Mar 29, 2010 · 10 comments

Comments

@fishman
Copy link

fishman commented Mar 29, 2010

if i try to use any cursor keys it will exit command-t and insert a A,B,C or D in the text.

also backspace is just moving backwards for me and not deleting any characters

@wincent
Copy link
Owner

wincent commented Mar 29, 2010

Most likely this is due to a limitation of your terminal. If you try it in the GUI version of VIM you'll see that it works. The problem is that on some terminals mappings like "<Left>" and "<Right>" don't get recognized by VIM because the terminal sends those characters as escape sequences.

For example, the bindings you're talking about get set up like this by the plug-in:

noremap <silent> <buffer> <BS> :call CommandTBackspacePressed()<CR>
noremap <silent> <buffer> <Left> :call CommandTCursorLeft()<CR>
noremap <silent> <buffer> <Right> :call CommandTCursorRight()<CR>
noremap <silent> <buffer> <Up> :call CommandTSelectPrev()<CR>
noremap <silent> <buffer> <Down> :call CommandTSelectNext()<CR>

I think you'll find that if you try to set up any mappings at all using <BS>, <Left>, <Right>, <Left>, <Up> or <Down> you'll get similar results. You could test that out by entering some mappings like this:

noremap <silent> <buffer> <Left> :echo 'Left pressed'<CR>

And so on...

The actual solution to the problem would be for you to find out how to express the escape sequence that your terminal is sending to VIM and use that in the mappings instead of "<Left>", "<Right>" and so on.

At the moment I haven't provided settings for overriding those mappings (although I will in a future version), so for now you would have to edit the plugin to insert your own mappings.

Cheers,
Wincent

P.S. The GitHub repo is just a mirror of the official repo at git.wincent.com, and the official issue tracker is at https://wincent.com/issues

@fishman
Copy link
Author

fishman commented Mar 29, 2010

ok ill keep that in mind. however, left and right work fine in the terminal. the issue must be somewhere in the ruby part

@wincent
Copy link
Owner

wincent commented Mar 29, 2010

Try the GUI version of VIM and you'll see that the issue isn't in the Ruby part.

Also, try my suggestion above to demonstrate that mappings using <left> etc don't work in your terminal.

Cheers,
Wincent

@fishman
Copy link
Author

fishman commented Mar 29, 2010

not sure what youre trying to prove. i totally believe it when you say that your map works just fine in macvim.
however ive been using a custom map for my left right keys for ages. so the answer has to be somewhere in between. if its not vim its gotta be related to the ruby bindings.

since i didn't exactly read the source and am not sure how the ruby bindings work thats just a wild guess.

@wincent
Copy link
Owner

wincent commented Mar 30, 2010

I'm only speculating, but what you describe exactly matches the VT100 special key codes listed here:

http://ascii-table.com/ansi-escape-sequences-vt-100.php

ie. "up" is actually ESC A, "down" is ESC B, "right" is ESC C, and "left" is ESC D

Which would explain why you're seeing "exit command-t and insert a A,B,C or D in the text" (ie. ESC dimisses Command-T and then the unwanted letter is inserted in the text.)

If there is something I can do to compensate for this behavior in a way that doesn't break other users' environments I will, but I don't know right now what would be needed; I'm merely explaining what I think is going on.

Cheers,
Wincent

@fishman
Copy link
Author

fishman commented Mar 30, 2010

ahhh the obivous. you just gave me an idea and it works, thanks! if i remove the map for esc the maps for left/right/up/down work of course.

the question is how can i map esc without breaking the rest

@wincent
Copy link
Owner

wincent commented Mar 30, 2010

Well you could just comment out the map for ESC and use Control-C to dismiss instead which does the same thing.

I'd still like to figure out why this is happening though. Could possibly be something to do with 'timeout', 'ttimeout', 'timeoutlen' and 'ttimeoutlen' settings but I haven't yet been able to figure it out here yet.

Cheers,
Wincent

@fishman
Copy link
Author

fishman commented Mar 30, 2010

well apparently fuzzyfinder uses insertleave to handle the esc. mapping esc doesn't work in vim. ill stick with c-c for now

@fishman
Copy link
Author

fishman commented Mar 30, 2010

another thing. the only works in insert mode for me. in normal mode its so i needed to change your c-h map as well. not sure why you mapped c-h and c-l but i thought id let you know. cheers

@wincent
Copy link
Owner

wincent commented Apr 2, 2010

I've made a copy of this ticket over at:

https://wincent.com/issues/1531

I'm going to close this ticket because I don't want to have issues being tracked in two separate places.

wincent added a commit that referenced this issue Jul 4, 2022
So I can see backtraces on Arch:

    yay -S gdb

Core dump files get written to `/var/lib/systemd/coredump/`, owned as
root, and zstd-compressed, so to read them, you have to do something
like:

    # unzstd /var/lib/systemd/coredump/core.nvim.1000.008a013d9f0d4e769d9dbcfdd9d9584a.13538.1656944479000000.std
    # chmod 666 /var/lib/systemd/coredump/core.nvim.1000.008a013d9f0d4e769d9dbcfdd9d9584a.13538.1656944479000000
    $ gdb nvim /var/lib/systemd/coredump/core.nvim.1000.008a013d9f0d4e769d9dbcfdd9d9584a.13538.1656944479000000
    (gdb) bt

Which shows (excerpted):

    Core was generated by `nvim'.
    Program terminated with signal SIGSEGV, Segmentation fault.

    warning: Section `.reg-xstate/13538' in core file too small.
    #0  match_thread (thread_args=0x55d4e0213230) at matcher.c:393
    393             haystack_t *match = args->corpus->haystacks[i];
    [Current thread is 1 (Thread 0x7fcda9b93740 (LWP 13538))]
    (gdb) bt
    #0  match_thread (thread_args=0x55d4e0213230) at matcher.c:393
    #1  0x00007fcda9e0f5ff in commandt_matcher_run (matcher=0x55d4e07eb9e0, needle=0x7fcda9e110f7 "stuff")
        at matcher.c:211
    #2  0x00007fcda9e0fb28 in commandt_temporary_demo_function () at matcher.c:312
    #3  0x00007fcda9bce309 in lj_vm_ffi_call () at buildvm_x86.dasc:2701
    #4  0x00007fcda9bf3b5e in lj_ccall_func (L=<optimized out>, cd=<optimized out>)
        at /build/luajit/src/luajit-2.0-4c2441c/src/lj_ccall.c:1167
    ...
wincent added a commit that referenced this issue Jul 7, 2022
I'm on macOS right now, so not sure how this will look in GCC, but at
least with clang/lldb we find the smoking gun pretty directly here.

First, without `-O0`

    lldb --file nvim
    (lldb) r
    Process 33400 stopped
    * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x7669746967750013)
        frame #0: 0x0000000103411c08 commandt.so`commandt_calculate_match + 52
    commandt.so`commandt_calculate_match:
    ->  0x103411c08 <+52>: ldr    x8, [x8, #0x8]
        0x103411c0c <+56>: adds   x8, x8, #0x1
        0x103411c10 <+60>: cset   w8, eq
        0x103411c14 <+64>: mov    w9, #0x1
    Target 0: (nvim) stopped.
    (lldb) bt
    * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x29)
      * frame #0: 0x0000000103411c08 commandt.so`commandt_calculate_match + 52
        frame #1: 0x0000000103413174 commandt.so`match_thread + 252
        frame #2: 0x00000001be24826c libsystem_pthread.dylib`_pthread_start + 148

Same with `-O0`:

    Process 33773 stopped
    * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x7669746967750093)
        frame #0: 0x0000000103411c08 commandt.so`commandt_calculate_match(haystack=0x766974696775008b, matcher=0x0000600002166800) at match.c:132:38
       129       matchinfo_t m;
       130       /* long i; */
       131       float score = 1.0;
    -> 132       int compute_bitmasks = haystack->bitmask == UNSET_BITMASK;
       133       m.haystack = haystack;
       134       m.needle_p = matcher->needle;
       135       m.needle_length = matcher->needle_length;
    Target 0: (nvim) stopped.
wincent added a commit that referenced this issue Aug 27, 2022
As reported here:

    #393 (comment)

if `options.finders` is not set to (at least an empty) table, we freak
out with:

    lua/wincent/commandt/init.lua:343: bad argument #1 to 'pairs' (table expected, got nil)
This issue was closed.
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