hyprland-community / hyprls

A LSP server for Hyprland config files [maintainer=@ewen-lbh]
https://ewen.works/hyprls
MIT License
93 stars 4 forks source link

panic: runtime error: index out of range [-1] #17

Open appleynski opened 1 month ago

appleynski commented 1 month ago

Hi!

I have hyprls installed on Arch Linux and running fine under NeoVim. However, when running in VSCode with HyprLS extension, I'm getting the following:

2024-07-23T18:49:43.406+0200    DEBUG   hyprls/main.go:25   going to start server
2024-07-23T18:49:43.406+0200    DEBUG   hyprls@v0.2.0/main.go:18    starting server
panic: runtime error: index out of range [-1]

goroutine 6 [running]:
github.com/ewen-lbh/hyprls/parser.Parse({0xc000147b00, 0x856})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/parser/lowlevel.go:254 +0xcc9
github.com/ewen-lbh/hyprls.parse({0xc0005d20c0?, 0x75ac00?})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/state.go:31 +0xb8
github.com/ewen-lbh/hyprls.Handler.DocumentColor({{0xc0002b8000?, 0x4c?}, 0x8000?}, {0x72c680?, 0xc000592080?}, 0x0?)
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/color.go:29 +0x49
go.lsp.dev/protocol.serverDispatch({0x888aa0, 0xc00030f8c0}, {0x88e508, 0xc000012f90}, 0xc000592060, {0x7b1fec1a26c8, 0xc0001dfbc0})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:338 +0x6dbd
github.com/ewen-lbh/hyprls.StartServer.ServerHandler.func1({0x888aa0, 0xc00030f8c0}, 0xc000592060, {0x7b1fec1a26c8, 0xc0001dfbc0})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:36 +0x7e
go.lsp.dev/jsonrpc2.(*conn).run(0xc000118cd0, {0x888aa0, 0xc00030f8c0}, 0xc000012fa8)
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:206 +0x33f
created by go.lsp.dev/jsonrpc2.(*conn).Go in goroutine 1
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:189 +0x8f
[Error - 6:49:45 PM] Server process exited with code 2.
[Info  - 6:49:45 PM] Connection to server got closed. Server will restart.
true
2024-07-23T18:49:45.412+0200    DEBUG   hyprls/main.go:25   going to start server
2024-07-23T18:49:45.412+0200    DEBUG   hyprls@v0.2.0/main.go:18    starting server
panic: runtime error: index out of range [-1]

goroutine 13 [running]:
github.com/ewen-lbh/hyprls/parser.Parse({0xc0000abb00, 0x856})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/parser/lowlevel.go:254 +0xcc9
github.com/ewen-lbh/hyprls.parse({0xc0004a5680?, 0x88bfc0?})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/state.go:31 +0xb8
github.com/ewen-lbh/hyprls.Handler.DocumentSymbol({{0xc0002d0000?, 0x4c?}, 0x8000?}, {0x72c800?, 0xc000509c40?}, 0x0?)
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/symbols.go:12 +0x49
go.lsp.dev/protocol.serverDispatch({0x888aa0, 0xc000177500}, {0x88e508, 0xc00013e6d8}, 0xc000509c20, {0x788d2d5d94f8, 0xc000225100})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:386 +0x8023
github.com/ewen-lbh/hyprls.StartServer.ServerHandler.func1({0x888aa0, 0xc000177500}, 0xc000509c20, {0x788d2d5d94f8, 0xc000225100})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:36 +0x7e
go.lsp.dev/jsonrpc2.(*conn).run(0xc0005934a0, {0x888aa0, 0xc000177500}, 0xc00013e6f0)
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:206 +0x33f
created by go.lsp.dev/jsonrpc2.(*conn).Go in goroutine 1
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:189 +0x8f
[Error - 6:49:45 PM] Server process exited with code 2.
[Info  - 6:49:45 PM] Connection to server got closed. Server will restart.
true
2024-07-23T18:49:45.612+0200    DEBUG   hyprls/main.go:25   going to start server
2024-07-23T18:49:45.612+0200    DEBUG   hyprls@v0.2.0/main.go:18    starting server
panic: runtime error: index out of range [-1]

goroutine 12 [running]:
github.com/ewen-lbh/hyprls/parser.Parse({0xc0000abb00, 0x856})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/parser/lowlevel.go:254 +0xcc9
github.com/ewen-lbh/hyprls.parse({0xc00049e0c0?, 0x88bfc0?})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/state.go:31 +0xb8
github.com/ewen-lbh/hyprls.Handler.DocumentSymbol({{0xc0004c6000?, 0x4c?}, 0x8000?}, {0x72c800?, 0xc0002be020?}, 0x0?)
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/symbols.go:12 +0x49
go.lsp.dev/protocol.serverDispatch({0x888aa0, 0xc00028d0b0}, {0x88e508, 0xc000210de0}, 0xc0002be000, {0x7bc49da523b8, 0xc00058c040})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:386 +0x8023
github.com/ewen-lbh/hyprls.StartServer.ServerHandler.func1({0x888aa0, 0xc00028d0b0}, 0xc0002be000, {0x7bc49da523b8, 0xc00058c040})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:36 +0x7e
go.lsp.dev/jsonrpc2.(*conn).run(0xc000514af0, {0x888aa0, 0xc00028d0b0}, 0xc000210df8)
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:206 +0x33f
created by go.lsp.dev/jsonrpc2.(*conn).Go in goroutine 1
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:189 +0x8f
[Error - 6:49:45 PM] Server process exited with code 2.
[Info  - 6:49:45 PM] Connection to server got closed. Server will restart.
true
2024-07-23T18:49:45.810+0200    DEBUG   hyprls/main.go:25   going to start server
2024-07-23T18:49:45.810+0200    DEBUG   hyprls@v0.2.0/main.go:18    starting server
panic: runtime error: index out of range [-1]

goroutine 34 [running]:
github.com/ewen-lbh/hyprls/parser.Parse({0xc0001bbb00, 0x856})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/parser/lowlevel.go:254 +0xcc9
github.com/ewen-lbh/hyprls.parse({0xc00052c000?, 0x88bfc0?})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/state.go:31 +0xb8
github.com/ewen-lbh/hyprls.Handler.DocumentSymbol({{0xc000512000?, 0x4c?}, 0x8000?}, {0x72c800?, 0xc000016040?}, 0x0?)
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/symbols.go:12 +0x49
go.lsp.dev/protocol.serverDispatch({0x888aa0, 0xc00026d740}, {0x88e508, 0xc00019f200}, 0xc000016020, {0x79f7181a09b8, 0xc000255b00})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:386 +0x8023
github.com/ewen-lbh/hyprls.StartServer.ServerHandler.func1({0x888aa0, 0xc00026d740}, 0xc000016020, {0x79f7181a09b8, 0xc000255b00})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:36 +0x7e
go.lsp.dev/jsonrpc2.(*conn).run(0xc00042b040, {0x888aa0, 0xc00026d740}, 0xc00019f218)
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:206 +0x33f
created by go.lsp.dev/jsonrpc2.(*conn).Go in goroutine 1
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:189 +0x8f
[Error - 6:49:45 PM] Server process exited with code 2.
[Info  - 6:49:45 PM] Connection to server got closed. Server will restart.
true
2024-07-23T18:49:45.898+0200    DEBUG   hyprls/main.go:25   going to start server
2024-07-23T18:49:45.898+0200    DEBUG   hyprls@v0.2.0/main.go:18    starting server
panic: runtime error: index out of range [-1]

goroutine 7 [running]:
github.com/ewen-lbh/hyprls/parser.Parse({0xc000141b00, 0x856})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/parser/lowlevel.go:254 +0xcc9
github.com/ewen-lbh/hyprls.parse({0xc0004c8000?, 0x88bfc0?})
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/state.go:31 +0xb8
github.com/ewen-lbh/hyprls.Handler.DocumentSymbol({{0xc0003ea000?, 0x4c?}, 0x8000?}, {0x72c800?, 0xc0003aa020?}, 0x0?)
    /home/krzysztof/.local/share/go/pkg/mod/github.com/ewen-lbh/hyprls@v0.2.0/symbols.go:12 +0x49
go.lsp.dev/protocol.serverDispatch({0x888aa0, 0xc0002941e0}, {0x88e508, 0xc0001248e8}, 0xc0003aa000, {0x7f992426b938, 0xc00038a000})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:386 +0x8023
github.com/ewen-lbh/hyprls.StartServer.ServerHandler.func1({0x888aa0, 0xc0002941e0}, 0xc0003aa000, {0x7f992426b938, 0xc00038a000})
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/protocol@v0.12.0/server.go:36 +0x7e
go.lsp.dev/jsonrpc2.(*conn).run(0xc000502370, {0x888aa0, 0xc0002941e0}, 0xc000124900)
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:206 +0x33f
created by go.lsp.dev/jsonrpc2.(*conn).Go in goroutine 1
    /home/krzysztof/.local/share/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/conn.go:189 +0x8f
[Error - 6:49:45 PM] Server process exited with code 2.
[Error - 6:49:45 PM] The Hypr server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Is there any additional info I can provide to help fix this issue?

Thanks!

ewen-lbh commented 1 month ago

Hi! Thx for the bug report !

If you're comfortable with it, sharing the contents of the file you were on when this happened, and especially the line where your cursor was, would be really helpful ;)

appleynski commented 1 month ago

I was browsing git diffs in VSCode, but it looks like the error showed up when the cursor was at the beginning of the first line of this hyprlock.conf file:

# $text_color = rgba(DFE2EFFF)
# $entry_background_color = rgba(0F131C11)
# $entry_border_color = rgba(8B909F55)
# $entry_color = rgba(C1C6D6FF)
$text_color = rgba(FFFFFFFF)
$entry_background_color = rgba(33333311)
$entry_border_color = rgba(3B3B3B55)
$entry_color = rgba(FFFFFFFF)
$font_family = Rubik Light
$font_family_clock = Rubik Light
$font_material_symbols = Material Symbols Rounded

background {
    # color = rgba(0A0E17FF)
    color = rgba(000000FF)
    # path = {{ SWWW_WALL }}
    # path = screenshot
    # blur_size = 5
    # blur_passes = 4
}
input-field {
    monitor =
    size = 250, 50
    outline_thickness = 2
    dots_size = 0.1
    dots_spacing = 0.3
    outer_color = $entry_border_color
    inner_color = $entry_background_color
    font_color = $entry_color
    # fade_on_empty = true

    position = 0, 20
    halign = center
    valign = center
}

label { # Clock
    monitor =
    text = $TIME
    shadow_passes = 1
    shadow_boost = 0.5
    color = $text_color
    font_size = 65
    font_family = $font_family_clock

    position = 0, 300
    halign = center
    valign = center
}
label { # Greeting
    monitor =
    text = hi $USER !!!
    shadow_passes = 1
    shadow_boost = 0.5
    color = $text_color
    font_size = 20
    font_family = $font_family

    position = 0, 240
    halign = center
    valign = center
}
label { # lock icon
    monitor =
    text = lock
    shadow_passes = 1
    shadow_boost = 0.5
    color = $text_color
    font_size = 21
    font_family = $font_material_symbols

    position = 0, 65
    halign = center
    valign = bottom
}
label { # "locked" text
    monitor =
    text = locked
    shadow_passes = 1
    shadow_boost = 0.5
    color = $text_color
    font_size = 14
    font_family = $font_family

    position = 0, 45
    halign = center
    valign = bottom
}

label { # Status
    monitor =
    text = cmd[update:5000] ${XDG_CONFIG_HOME:-$HOME/.config}/hypr/hyprlock/status.sh
    shadow_passes = 1
    shadow_boost = 0.5
    color = $text_color
    font_size = 14
    font_family = $font_family

    position = 30, -30
    halign = left
    valign = top
}
ewen-lbh commented 1 month ago

Oh yeah for now only config files for hyprland itself are supported, sorry ><