Giter Site home page Giter Site logo

Comments (25)

sholderbach avatar sholderbach commented on August 23, 2024 1

Great @aslynatilla!

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024 1

There is a brace matching logic that will continue to a new line if the brace is not closed included with the demo binary.

so

> {<Cursor><Enter>

should result in

> {
<Cursor>

but after

> {
}<Cursor><Enter>

the program should exit.

Implementation:

fn validate(&self, line: &str) -> ValidationResult {

from reedline.

elferherrera avatar elferherrera commented on August 23, 2024 1

@aslynatilla forgot to mention, could you add the same case for the vim event file?

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024 1

OK either we deal with an invisible character/unicode scalar on the reedline side or there is a bug on the crossterm side.
You could give the new main cargo run -- -k another go if we have different unicode scalar values.
Other than that I was dabbling with JT on a change to how we pull the events from crossterm to drain all events between refreshs but this should only affect timing of events/display stuff but not how the internal string looks like. When I get that finished we might instrument that again and probably have to open the issue with crossterm

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024 1

Tried a run with cargo run -- -k and... it doesn't look like there are different unicode scalar values.
Specifically:

Char: { code: 0x00007b; Modifier SHIFT | CONTROL | ALT; Flags 0b000111
Char: } code: 0x00007d; Modifier SHIFT | CONTROL | ALT; Flags 0b000111
Char: [ code: 0x00005b; Modifier CONTROL | ALT; Flags 0b000110
Char: ] code: 0x00005d; Modifier CONTROL | ALT; Flags 0b000110

It apparently makes sense. The same considerations from above are still valid. You need to press Backspace twice to delete a bracket, if it is the last printed character; it "goes back to normal" if you typed something after that - you can delete both the following character and the bracket by pressing Backspace twice.

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024 1

@aslynatilla I would vote for closing the issue here as your fixed the direct input problem with your PR. Would you mind describing the issue of the invisible character to delete on crossterm's bugtracker with info regarding platform, terminal emulator etc.?

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024 1

I won't probably be able to do it tonight, but... it's definitely something I can do in the next days! Should I quote this issue?

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024 1

OK after discussing with @aslynatilla the remaining invisible character issue seems to be stemming from VS codes internal terminal and key detection. No need to file with crossterm

from reedline.

elferherrera avatar elferherrera commented on August 23, 2024

In theory, this line should take care of it.

Do you mind running reedline with the flag -k (cargo run -- -k)?
This flag will show you the events that are being pressed in reedline

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

Building and compiling last commit on reedline's main branch prints:

cargo run -- -k
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target\debug\reedline.exe -k`
Ready to print events (Abort with ESC):
Event::Key(KeyEvent { code: Char('a'), modifiers: NONE })
Event::Key(KeyEvent { code: Char('s'), modifiers: NONE })
Event::Key(KeyEvent { code: Char('['), modifiers: CONTROL | ALT })
Event::Key(KeyEvent { code: Char('{'), modifiers: SHIFT | CONTROL | ALT })
Event::Key(KeyEvent { code: Esc, modifiers: NONE })

Everything seems ok, there!

from reedline.

elferherrera avatar elferherrera commented on August 23, 2024

Oohh... you see that your input requires SHIFT CONTROL ALT

can you try adding that case to the line I showed you? And run again reedline

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

Adding the following case allows me to write { or }.

(m, KeyCode::Char(c)) if m == KeyModifiers::CONTROL | KeyModifiers::ALT | KeyModifiers::SHIFT => {
   ReedlineEvent::Edit(vec![EditCommand::InsertChar(c)])
}

However, the "phantom character" problem is still there.
Moreover, since this might be related to this issue... I could see the cursor/caret flickering, going from the start to the end of the line.

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024

Would you mind opening a PR for the change?

For the phantom character problem could you check if the non brace AltGr characters (not []{})also cause this issue? I would like to exclude an interaction with the brace matching logic used to decide if enter moves to a new line or executes.

The cursor flickering is a known issue due to the current (re)paint implementation and shouldnt be related to the input side.

from reedline.

elferherrera avatar elferherrera commented on August 23, 2024

That cursor flickering happens to me as well. I don't know why it does it.

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024

Could you try typing a [ or { somewhere in the middle of an existing line? Would the cursor actually jump to the end? my wild guess would be that crossterm somehow runs into an unicode normalization issue and the รจ as a e with accent grave somehow also triggers the Ctrl+e move to end keybinding.

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

@sholderbach I can open the PR with that change, no problem!
Not sure about the interactions... But I can try as soon as I am at my PC again!

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024

On Linux I wasn't able to reproduce the phantom characters with AltGr [ or { on a German keymap.
Your key event log seems to look right so it doesn't directly point to the various edgecases in crossterm related to various modifier keys.

Examples:
crossterm-rs/crossterm#536

crossterm-rs/crossterm#540

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

I also tested typing in the middle of an existing line; the cursor jumps back to its "current" position, not the end of the line.
Another discovery I made is that... "the phantom character" stops from pressing Enter and getting the usual message:

Our buffer: <content of the buffer>

Instead, pressing Enter places a new line. Maybe this can reveal something more about the other problem - which probably is not related to the current issue, though.

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

My bad, then, since it looks like it works, consistently, as intended! (I didn't consider/notice that...!)

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024

Can you narrow down for which characters you observe the phantom character ๐Ÿ‘ป ? Maybe let's compare the signals with the enhanced -k flag

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

It looks like it is related to typing anything that requires AltGr.
An example are @ and # on my keyboard, which are respectively a combination of AltGr + รฒ and AltGr + ร .
Any other key doesn't produce the problem, according to my observations.

EDIT: Also note that running with -k shows that...

Event::Key(KeyEvent { code: Char('['), modifiers: CONTROL | ALT })
Event::Key(KeyEvent { code: Char('{'), modifiers: SHIFT | CONTROL | ALT }) <--- pressed Backspace twice here
Event::Key(KeyEvent { code: Backspace, modifiers: NONE })

...one of the Backspace inputs is not considered. However, pressing another "normal" key works as intended and you may continue typing.

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024

@aslynatilla On which platform/terminal emulator are you testing?
So the Euro symbol and the closing ] are not causing the same phenomenon? Then it might point to the accent being somewhat weird.
On the German keyboard accents are handled by keys that are pressed but don't print at first, you either type the vowel for use as accents or a space to get ^ and so on. So they behave like phantom characters on the German keyboard (and seem to be abstracted away by either the os, the terminal emulator or crossterm??) and only pressing the accent key does not bubble up an event to reedline. But that might be wild speculation. Do vowels afterwards get modified?

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

@sholderbach I forgot about the โ‚ฌ symbol, to be fair. It causes the same phenomenon for me.
Your observations made me double-check something and I can now specify that:

Typing [ prints it, but you need to use Backspace twice to delete the bracket.
However, if you type another character, this is not true: typing [e for example requires two Backspaces in order to delete it completely; typing [{ requires three Backspaces, though - two for deleting the curly bracket, one for deleting the square bracket.

My gut feeling says it might be something related to AltGr... as if pressing that key with another button set a flag that needs to be reset, but is not. It also seems only related to deletion, since insertion after a character using AltGr works fine.

from reedline.

aslynatilla avatar aslynatilla commented on August 23, 2024

While I was documenting the bug on crossterm's bug-tracker, I double-checked something I didn't think about earlier.
I have always tried this using nushell as an integrated terminal in Visual Studio Code.
However, running reedline (with cargo run) on the current main branch in nushell, opened as a Window Terminal window, does not present the same issue.
I am now thinking this might be Visual Studio Code's problem, more than crossterm's.

from reedline.

sholderbach avatar sholderbach commented on August 23, 2024

Can you reproduce the same issue with the mainline nushell using rustyline under VS code. VS code has it's own troubled history with key mapping independent of what might be reasonably intercepted as keybindings (e.g. under linux microsoft/vscode#23991 open for years) as it's turtles all the way down from VS code with its components, Electron and the Chromium engine.

from reedline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.