Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Menu.lua crashes when removing single letters (CTRL+BS) in command palette. #847

Closed
Sneakpeakcss opened this issue Feb 18, 2024 · 0 comments

Comments

@Sneakpeakcss
Copy link
Contributor

#745 v2 basically.

[uosc] stack traceback:
[uosc] 	...4-v3/scripts/uosc/elements/Menu.lua:951: in function 'maybe'
[uosc] 	...4-v3/scripts/uosc/elements/Menu.lua:1100: in function 'fn'
[uosc] 	...4-v3/scripts/uosc/elements/Menu.lua:1079: in function 'fn'
[uosc] 	mp.defaults:206: in function 'fn'
[uosc] 	mp.defaults:65: in function 'handler'
[uosc] 	mp.defaults:382: in function 'handler'
[uosc] 	mp.defaults:512: in function 'call_event_handlers'
[uosc] 	mp.defaults:554: in function 'dispatch_events'
[uosc] 	mp.defaults:505: in function <mp.defaults:504>
[uosc] 	[C]: at 0x7ff7bdf33f70
[uosc] 	[C]: at 0x7ff7bdf33610
[uosc] Lua error: ...4-v3/scripts/uosc/elements/Menu.lua:855: attempt to concatenate a nil value

This only happens when removing either a single letter a which crashes instantly, or a set of single letters a a a a a, where crash happens at the point of removing the last one. If at any point there's 2 letters together: a a ab a a then it works without issues.

local tail = old_query:match(init_pat) or ''
-- If there's only one, we extend the tail with opposite type chars
if tail and #tail == 1 then
tail = tail .. old_query:sub(1, #old_query - #tail):match(init_pat == word_pat and other_pat or word_pat)
end
pos = pos - #tail

- tail = tail .. old_query:sub(1, #old_query - #tail):match(init_pat == word_pat and other_pat or word_pat)
+ tail = tail .. (old_query:sub(1, #old_query - #tail):match(init_pat == word_pat and other_pat or word_pat) or '')

This change seems to fix it on my end.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant