martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 259 forks source link

vis:pipe(): don't segfault if vis->win isn't present #1108

Closed rnpnr closed 11 months ago

rnpnr commented 12 months ago

fixes #1107

Note: This is a bit of a hack and I don't think it should actually be applied. It only works when file is changed via the else branch of the check that follows.

I will work on a proper fix later if no one has anything better.

rnpnr commented 11 months ago

The commit I just pushed is a little better. vis:pipe() will now throw an error if you try to call it without specifying a file before a window is open.

You can test it by adding something like the following to visrc.lua:

vis.events.subscribe(vis.events.FILE_OPEN, function()
    err, out = vis:pipe("echo no explosion")
    if (out) then
        vis:message(out)
    end
end)