micro-editor / micro-editor/micro
Plugin variables do not update once they are modified by micro.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
Inside of plugins, the tabs variable only references the initial tabs that were created from the command line. If any new tabs are created using the tab command inside of micro, the Lua plugin will not see them.
I don't know much about golang or lua, but I was able to very poorly fix the problem by adding another L.SetGlobal() method into the function NewTab whenever a new tab is created. This would also have to be done whenever tabs is changed. I'm assuming there is a better method that I don't know about due to my lack of knowledge with golang.
I'm not sure if the lua library is supposed to store references to the slice, but for one reason or another, the tabs variable in lua scripts doesn't stay up to date with the global tabs variable in go.
A simple lua script that counts the number of open tabs. Open micro, then open a few tabs. The count will be incorrect.
-- $HOME/.config/micro/plugins/tabs/tabs.lua
function count()
messenger:Message("Number of Tabs: " .. #tabs)
end
MakeCommand("tabs", "tabs.count", 0)
Specifications
Commit hash: 26da85d (and older versions)
OS: Debian 9
Terminal: xfce-terminal
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 plugin variable setup and the NewTab function mentioned in the issue, including the existing L.SetGlobal call. Reproduce the problem with the supplied Lua count script, then inspect where tabs changes and determine how the Lua-visible value should stay current. Done means the command reports the current number of open tabs after creating additional tabs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, lua
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100