hismailbulut / Neoray

Simple and lightweight GUI client for Neovim
MIT License
148 stars 5 forks source link

Crash on C-ScrollWheel* mapping #7

Closed andis-sprinkis closed 3 years ago

andis-sprinkis commented 3 years ago

After adding this code to my init.vim

let s:fontname = "CascadiaCodePL"
let s:fontsize = 10

function! AdjustFontSize(amount)
  let s:fontsize = s:fontsize+a:amount
  let s:guifont = s:fontname . ':h' . s:fontsize
  execute 'set guifont=' . s:guifont
endfunction

call AdjustFontSize(0)

noremap <C-ScrollWheelUp> :call AdjustFontSize(1)<CR>
noremap <C-ScrollWheelDown> :call AdjustFontSize(-1)<CR>
inoremap <C-ScrollWheelUp> <Esc>:call AdjustFontSize(1)<CR>a
inoremap <C-ScrollWheelDown> <Esc>:call AdjustFontSize(-1)<CR>a

and doing C-ScrollWheel* in a new neoray instance, it would exit with this error: image

Manually calling :set guifont=CascadiaCodePL:h{some number} works fine.

Crash log:

NEORAY v0.0.7 Release Crash Report 2021-08-26 18:40:50.8429361 +0000 UTC
Please open an issue in github with this file.
The program is crashed because of the following reasons:
[FATAL] [NEORAY] [PANIC!] runtime error: invalid memory address or nil pointer dereference

goroutine dump:
goroutine 1 [running, locked to thread]:
main.createCrashReport(0xc000194060, 0x5b)
    D:/a/neoray/neoray/src/logger.go:104 +0x545
main.logMessage(0x100000004, 0xc0005c5730, 0x2, 0x2)
    D:/a/neoray/neoray/src/logger.go:168 +0x27d
main.shutdownLogger()
    D:/a/neoray/neoray/src/logger.go:77 +0xb5
panic(0x1153c60, 0x10b9b50)
    C:/hostedtoolcache/windows/go/1.16.7/x64/src/runtime/panic.go:965 +0x1c7
main.(*FontFace).Resize(0x0, 0xc041100000)
    D:/a/neoray/neoray/src/fontface.go:68 +0x6c
main.(*Font).Resize(0x13163b8, 0x41100000)
    D:/a/neoray/neoray/src/font.go:136 +0x6f
main.(*Renderer).setFontSize(0x13163b8, 0xc041100000)
    D:/a/neoray/neoray/src/renderer.go:78 +0x94
main.(*UIOptions).setGuiFont(0x1316490, 0xc0005ca2e8, 0x11)
    D:/a/neoray/neoray/src/uioptions.go:52 +0x485
main.option_set(0xc0005c6a70, 0x1, 0x1)
    D:/a/neoray/neoray/src/redrawevents.go:110 +0x318
main.handleRedrawEvents()
    D:/a/neoray/neoray/src/redrawevents.go:32 +0x15de
main.(*Editor).update(0x1316260)
    D:/a/neoray/neoray/src/editor.go:168 +0x3a
main.(*Editor).MainLoop(0x1316260)
    D:/a/neoray/neoray/src/editor.go:148 +0x2fc
main.main()
    D:/a/neoray/neoray/src/main.go:69 +0x2a5

goroutine 66 [chan send]:
main.(*NvimProcess).startUI.func2(0x1316260)
    D:/a/neoray/neoray/src/nvimproc.go:141 +0x11b
created by main.(*NvimProcess).startUI
    D:/a/neoray/neoray/src/nvimproc.go:135 +0x30a
hismailbulut commented 3 years ago

This now fixed in latest release. Also you can use the font size increase/decrease keybinding with mouse input. Just set them like this.

let neoray_key_increase_fontsize=<C-ScrollWheelUp>
andis-sprinkis commented 3 years ago

0.0.8 - these mappings work without crashing now, thank you :)