Skip to content

linenum-based hint forwards incorrect filename to program, with extra characters and newlines #5170

@aisamu

Description

@aisamu

Describe the bug
linenum-based hint forwards incorrect filename to program, with extra characters and newlines

To Reproduce

Given an arbitrary Node stacktrace output:

Trace: Called something
    at Object.<anonymous> (/Users/unimportant/unimportant/unimportant/node/unimportant/node_modules/@unimportant/unimportant/dist/browserClient.js:26714:9)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/unimportant/unimportant/unimportant/node/unimportant/node_modules/@unimportant/unimportant2/dist/index.js:58:21)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.@unimportant/dls (/Users/unimportant/unimportant/unimportant/node/unimportant/.next/server/pages/members.js:263:18)
    at __webpack_require__ (/Users/unimportant/unimportant/unimportant/node/unimportant/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./src/components/layout.tsx:7:68)
    at Object../src/components/layout.tsx (/Users/unimportant/unimportant/unimportant/node/unimportant/.next/server/pages/members.js:165:1)
    at __webpack_require__ (/Users/unimportant/unimportant/unimportant/node/unimportant/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./src/pages/members.tsx:10:76)

When I use the "insert-file-path" hint (kitty_mod+p>f), I get as a result (for the first detected match):

/Users/unimportant/unimportant/unimportant/node/unimportant/node_modules/@unimportant/unimportant/dist/browserClient.js:26714:9

That's perfect, working even when the terminal is narrow and the path spans multiple lines!

If I instead use a linenum-based hint, such as the one shown on the manual:

map ctrl+g kitten hints --type=linenum --linenum-action=tab vim +{line} {path}

Kitty includes two "incorrect" things when invoking vim:

  • ( as part of the path
  • Terminal newlines (^M) as part of the path when the match spans multiple lines

The complete invocation looks like (e.g.):

vim +26714 '(/Users/unimportant/unimportant/unimpor^Mtant/node/unimportant/node_modules/@unimportant/unimportant/dist/^MbrowserClient.js'

Environment details

kitty 0.25.1 created by Kovid Goyal
Darwin aisambp-stedi 20.6.0 Darwin Kernel Version 20.6.0: Tue Feb 22 21:10:41 PST 2022; root:xnu-7195.141.26~1/RELEASE_X86_64 x86_64
ProductName:    macOS ProductVersion:   11.6.5 BuildVersion:    20G527
Frozen: False
Paths:
  kitty: /nix/store/r8d55qdacv9mqk78sixkvql2xbfzwi7x-kitty-0.25.1/Applications/kitty.app/Contents/MacOS/kitty
  base dir: /nix/store/r8d55qdacv9mqk78sixkvql2xbfzwi7x-kitty-0.25.1/Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /nix/store/r8d55qdacv9mqk78sixkvql2xbfzwi7x-kitty-0.25.1/Applications/kitty.app/Contents/Resources/kitty/kitty
  system shell: /bin/zsh
Loaded config files:
  /Users/aisamu/.config/kitty/kitty.conf

Config options different from defaults:
bold_font            Iosevka Bold
bold_italic_font     Iosevka Bold Italic
copy_on_select       clipboard
font_family          Iosevka Medium
font_size            14.0
italic_font          Iosevka Medium Italic
Added shortcuts:
        cmd+o → kitten hints --type=linenum --linenum-action=tab vim +{line} {path}
[colors...]

Important environment variables seen by the kitty process:
        PATH                                /nix/store/r8d55qdacv9mqk78sixkvql2xbfzwi7x-kitty-0.25.1/Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
        LANG                                en_US.UTF-8
        SHELL                               /bin/zsh
        USER                                aisamu
        LC_CTYPE                            UTF-8

Additional context

  • Try to reproduce the problem with kitty --config NONE
    • kitty --config NONE -o 'map super+o kitten hints --type=linenum --linenum-action=tab vim +{line} {path}'

Thanks for writing Kitty.
It's tremendous!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions