helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.43k stars 2.48k forks source link

loop trying to navigate with l (and h) #11904

Open plutack opened 5 days ago

plutack commented 5 days ago

Summary

I get stuck in a back and forth loop when trying to move cursor focus with h and l depending on the direction I am taking.

Reproduction Steps

https://asciinema.org/a/IF0OH5O7oAV8ODHVTgIbENy1b

I tried this:

  1. paste this text in an empty file; नमस्कार
  2. move to the beginning of word
  3. in normal mode. use l to navigate through the text

I expected this to happen: move pass the word to the end of the word

Instead, this happened: I get stuck in the middle

Helix log

Try 'tail --help' for more information.

╭─plutack@talutpc in ~/projects/go/learning-go/ch-3/one via  v1.23.2 as 🧙 took 2ms [🔴] × tail -l50 /home/plutack/.cache/helix/helix.log tail: invalid option -- 'l' Try 'tail --help' for more information.

╭─plutack@talutpc in ~/projects/go/learning-go/ch-3/one via  v1.23.2 as 🧙 took 2ms [🔴] × tail --lines 50 /home/plutack/.cache/helix/helix.log 2024-10-16T17:41:55.114 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:55.246 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:55.379 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:55.516 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:55.648 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:55.769 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:55.886 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:56.137 helix_term::application [DEBUG] received editor event: IdleTimer 2024-10-16T17:41:56.276 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:56.277 helix_lsp::transport [INFO] gopls -> {"jsonrpc":"2.0","method":"textDocument/formatting","params":{"options":{"insertSpaces":false," 2024-10-16T17:41:56.279 helix_lsp::transport [INFO] gopls <- {"jsonrpc":"2.0","error":{"code":0,"message":"10:16: expected type, found ':=' (and 1 more erro 2024-10-16T17:41:56.279 helix_lsp::transport [ERROR] gopls <- ServerError(0): 10:16: expected type, found ':=' (and 1 more errors) 2024-10-16T17:41:56.279 helix_view::document [WARN] LSP formatting failed: protocol error: ServerError(0): 10:16: expected type, found ':=' (and 1 more erro 2024-10-16T17:41:56.279 helix_view::document [DEBUG] submitting save of doc 'Some("/home/plutack/projects/go/learning-go/ch-3/one/main.go")' 2024-10-16T17:41:56.281 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:56.292 helix_term::application [DEBUG] received editor event: DocumentSaved(Ok(DocumentSavedEvent { revision: 0, save_time: SystemTime { tv 2024-10-16T17:41:56.292 helix_lsp::transport [INFO] gopls -> {"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///home/ 2024-10-16T17:41:56.292 helix_lsp::file_event [DEBUG] Received file event for "/home/plutack/projects/go/learning-go/ch-3/one/main.go" 2024-10-16T17:41:56.292 helix_term::application [DEBUG] document Some("/home/plutack/projects/go/learning-go/ch-3/one/main.go") saved with revision 0 2024-10-16T17:41:56.292 helix_view::document [DEBUG] doc 2 revision updated 0 -> 0 2024-10-16T17:41:56.292 helix_view::editor [DEBUG] editor status: 'main.go' written, 13L 478B 2024-10-16T17:41:56.292 helix_lsp::file_event [DEBUG] Sending didChangeWatchedFiles notification to client 'gopls' 2024-10-16T17:41:56.292 helix_lsp::transport [INFO] gopls -> {"jsonrpc":"2.0","method":"workspace/didChangeWatchedFiles","params":{"changes":[{"type":2,"uri":"file:///home/plutack/projects/go/learning-go/ch-3/one/main.go"}]}} 2024-10-16T17:41:56.293 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:56.314 helix_lsp::transport [INFO] gopls <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/plutack/projects/go/learning-go/ch-3/one/main.go","diagnostics":[{"range":{"start":{"line":9,"character":15},"end":{"line":9,"character":15}},"severity":1,"source":"syntax","message":"expected type, found ':='"}]}} 2024-10-16T17:41:56.314 helix_term::application [DEBUG] received editor event: LanguageServerMessage((LanguageServerId(1v1), Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [Object {"message": String("expected type, found ':='"), "range": Object {"end": Object {"character": Number(15), "line": Number(9)}, "start": Object {"character": Number(15), "line": Number(9)}}, "severity": Number(1), "source": String("syntax")}], "uri": String("file:///home/plutack/projects/go/learning-go/ch-3/one/main.go")}) }))) 2024-10-16T17:41:56.349 helix_term::application [DEBUG] received editor event: Redraw 2024-10-16T17:41:56.350 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:56.525 helix_term::application [DEBUG] received editor event: IdleTimer 2024-10-16T17:41:56.778 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:57.028 helix_term::application [DEBUG] received editor event: IdleTimer 2024-10-16T17:41:57.640 helix_term::commands::typed [DEBUG] quitting... 2024-10-16T17:41:57.641 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:57.865 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:58.261 helix_view::editor [DEBUG] editor error: no such command: 'q1' 2024-10-16T17:41:58.262 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:59.558 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:41:59.809 helix_term::application [DEBUG] received editor event: IdleTimer 2024-10-16T17:41:59.995 helix_term::commands::typed [DEBUG] quitting... 2024-10-16T17:41:59.996 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:42:01.100 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0 2024-10-16T17:42:01.456 helix_term::job [DEBUG] waiting on jobs... 2024-10-16T17:42:01.456 helix_term::job [DEBUG] waiting on jobs... 2024-10-16T17:42:01.456 helix_lsp::file_event [DEBUG] Removing LSP client: 1v1 2024-10-16T17:42:01.456 helix_lsp::transport [INFO] gopls -> {"jsonrpc":"2.0","method":"shutdown","id":2} 2024-10-16T17:42:01.457 helix_lsp::transport [INFO] gopls <- {"jsonrpc":"2.0","result":null,"id":2} 2024-10-16T17:42:01.457 helix_lsp::transport [INFO] gopls <- null 2024-10-16T17:42:01.457 helix_lsp::transport [INFO] gopls <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2024/10/16 17:42:01 Shutdown session\n\tshutdown_session=1\n"}} 2024-10-16T17:42:01.457 helix_lsp::transport [INFO] gopls -> {"jsonrpc":"2.0","method":"exit"} 2024-10-16T17:42:01.462 helix_lsp::transport [ERROR] gopls err: <- StreamClosed

Platform

Linux

Terminal Emulator

foot version: 1.18.1 +pgo +ime +graphemes -assertions

Installation Method

AUR: helix-git package

Helix Version

helix 24.7 (a7651f5b)

eduardorittner commented 3 days ago

I'm not sure I understand, it's working fine for me, when you say you get stuck, do you mean you are unable to move the cursor? Also, l is for going one character to the right, not to the end of a word. You can press e to go to the end of the current word or w to go the start of the next word.

plutack commented 3 days ago

yes, I know i could possibly use e, w, b to jump words but what I show is not correct behaviour. If you checked the video i shared, you would see while on helix, pressing l keeps returning me A character back in a loop form which is not the proper behaviour.

move pass the word to the end of the word

when I say this, I meant using l, I should be able to transverse through a word/line regardless though one character at a time. That isn't what is happening in the video I shared. I think mentioning e or w in this context is dancing around a bug assuming this is reproducible by others.

eduardorittner commented 3 days ago

I see, makes sense, I was just trying to confirm what you meant since I wasn't able to reproduce the bug. I will try some more tomorrow

eduardorittner commented 2 days ago

Just triggered it, I was using the package from the official repos which was also on 24.7 but on an earlier commit. When I build from your commit I am able to reproduce the bug, which means it was introduced quite recently

eduardorittner commented 2 days ago

After using git bisect I found that the bad commit is c754949454a6c757a41f69bb0cadee6b8fc689d7. It's a dependency bump of some libraries which directly updates the unicode-segmentation library among some other ones. My guess is that the root cause is in the update to unicode-segmentation from 1.11 to 1.12, however I won't be able to look into this too much this weekend

eduardorittner commented 2 days ago

From the changes there are only 21 commits between the two versions, so it shouldn't be too hard to look through all of them

eduardorittner commented 2 days ago

This issue (later fixed here) mentions the "क" character which is the one the cursor gets stuck on, it's probably related to the bug we are seeing, but I'm pretty ignorant when it comes to unicode so any help on this would be greatly appreciated

eduardorittner commented 2 days ago

It's definitely the change from unicode-segmentation 1.11 to 1.12, running the code:

use unicode_segmentation::UnicodeSegmentation;

fn main() {
    let string = "नमस्कार";
        let mut g = string.graphemes(true).collect::<Vec<&str>>().into_iter();
        while let Some(c) = g.next() {
            print!("{c}, ")
        }
}

results in "न, म, स्, का, र," in 1.11 and "न, म, स्का, र," in 1.12, which means that previously there was a character boundary between "स्" and "का", but now they're interpreted as one character "स्का". I'm not sure exactly how this leads to the bug, but this is most likely the cause.