Trying to replace pane buff
Hi, Im writing a plugin that first outputs into a vsplit and I want to replace that buffer with the string I receive from my job:
newFname = fname.sub(fname, 1, -1* (string.len(ext) +1 )) .. ".diff." .. ext
local buf = buffer.NewBuffer("Running query, please wait. Might take up to 1-2 minutes", newFname)
local newPb = buffer.NewVSplitFromBuffer(buf, bp) -- added it to initlua
shell.JobSpawn(cmd, {pwd .. "assistant.py", fname}, nil, nil, onExit, newPb, newFname)
end
function onExit(output, args)
local pb, fname = args[1], args[2]
if output == nil then
micro.InfoBar():Message(string.format("Running assistant failed (nil) %s ", output ))
return
end
local buf2 = buffer.NewBuffer(output, fname)
pb:OpenBuffer(buf2)
micro.InfoBar():Message(string.format("Done" ))
return
end
But it is not happening. No errors, but content remains the same. Tried it with the parent PaneBuff, content is replaced, but with the buf not buf2.
What am I doing wrong? I'm looking for some guidance here.
Thanks! Semirke
Do I correctly understand that you need to just programmatically replace text of buffer? Maybe you just need buffer_variable.EventHandler:Insert(<location>, <text>)?
Hi,
no, I wanted to open a new vertical tab and first output something like "The plugin is running, please wait". Then replace that buffer. EventHandler:Replace might work well for me, thanks :) But i dont much understand why buffer replacing did not work out. Works with other tabs.
Tbh, I completely forgot about this, but Im much more familiar with the codebase now. I've added lots of cool features for myself (https://github.com/semirke/micro/tree/geigermerge) Ibelieve it worths checking out :) (Also made a big mistake by trying to merge one of the old PRs, but it was a way too late by the time I realised, but cleaned it up :D)
Thank you for making me remember and for the pointer :)
Bests, András
Vertical tab... OK... As I know current version of micro (what about your's don't know) don't have vertical tabs. I just can say that you can find in issues list issue about wrong resize logic that resize the wrong (the most left) pane. Now I fully don't trust the logic of splits so if you rely on them, don't be surprised
It looks like in your version can (you should ask maintainers of the project) be found something interesting but there is a problem... Absence of centralized fresh branch with up-to-date development. Now we have just a bunch of issues and PR's. Maybe you want to try to transform some parts of your custom version to separate PR? They will have a chance to be merged into master
@zyedidia maybe you will give @dmaluka (and @JoeKar) some more rights? ( • ᴗ - )
At least opportunity to assign labels. At most separate branch for example dev?
Vertical tab... OK... As I know current version of micro (what about your's don't know) don't have vertical tabs. I just can say that you can find in issues list issue about wrong resize logic that resize the wrong (the most left) pane. Now I fully don't trust the logic of splits so if you rely on them, don't be surprised
It looks like in your version can (you should ask maintainers of the project) be found something interesting but there is a problem... Absence of centralized fresh branch with up-to-date development. Now we have just a bunch of issues and PR's. Maybe you want to try to transform some parts of your custom version to separate PR? They will have a chance to be merged into master
@zyedidia maybe you will give @dmaluka (and @JoeKar) some more rights?
( • ᴗ - )At least opportunity to assign labels. At most separate branch for exampledev?
oh my, ofc you have! vsplit command.
Oh, since i checked the PR list here, I gave up on trying to get my change merged. So Im just doing it for me.
But I'll merge your stuff, too. The changes seem reasonable.