micro-editor / micro-editor/micro
When opening a file after micro has started, onBufPaneOpen is not triggered.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
Description of the problem or steps to reproduce
When a file is opened (using Ctrl-O) after micro has started, the onBufPaneOpen() method of the plugin is not triggered (while onBufferOpen() method is being triggered as expected).
This is an issue for plugins who wants to provide an "open on start" function and who needs to have access to the pane the buffer is sitting into.
Use the following dummy plugin in ~/.config/micro/plug/dummy/dummy.lua
local micro = import("micro")
local function pane_str(pane)
local ret = 'nil'
if pane then
ret = pane:ID()..':'..pane.Buf:GetName()
end
return ret
end
function onBufferOpen(buf)
micro.Log('>> onBufferOpen('..buf:GetName()..')')
micro.Log('<< onBufferOpen')
end
function onBufPaneOpen(pane)
micro.Log('>> onBufPaneOpen('..pane_str(pane)..')')
micro.Log('<< onBufPaneOpen')
end
function init()
micro.Log('>> init')
micro.Log('<< init')
end
Start micro blank (i.e. no file specified on the command line).
micro -debug
Open a file using Ctrl-O [dummy.lua]
Close the file using Ctrl-Q
The log file will look like this:
2020/03/27 14:06:58 Micro started
2020/03/27 14:07:00 >> onBufferOpen(No name)
2020/03/27 14:07:00 << onBufferOpen
2020/03/27 14:07:00 >> onBufPaneOpen(0:No name)
2020/03/27 14:07:00 << onBufPaneOpen
2020/03/27 14:07:00 >> onBufferOpen(No name)
2020/03/27 14:07:00 << onBufferOpen
2020/03/27 14:07:00 >> onBufPaneOpen(0:No name)
2020/03/27 14:07:00 << onBufPaneOpen
2020/03/27 14:07:00 >> onBufferOpen(Log)
2020/03/27 14:07:00 << onBufferOpen
2020/03/27 14:07:00 >> init
2020/03/27 14:07:00 << init
2020/03/27 14:07:04 >> onBufferOpen(dummy.lua)
2020/03/27 14:07:04 << onBufferOpen
Showing that onBuffPaneOpen() is not being called for our file 'dummy.lua'.
Specifications
OS: Ubuntu 19.10
Version: 2.0.3-dev.21
Commit hash: 1cf9537
Compiled on March 27, 2020
Happens also with the latest official release 2.0.2.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Ctrl-O file-opening path and comparing how it dispatches onBufferOpen and onBufPaneOpen. Reproduce the behavior with the supplied dummy.lua plugin and debug log. Done means opening a file after startup triggers onBufPaneOpen with the pane containing the buffer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, lua
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100