Skip to content

Fix tab ID becoming 0 once the tab contains splits - #4208

Open
4RH1T3CT0R7 wants to merge 1 commit into
micro-editor:masterfrom
4RH1T3CT0R7:fix/4186
Open

Fix tab ID becoming 0 once the tab contains splits#4208
4RH1T3CT0R7 wants to merge 1 commit into
micro-editor:masterfrom
4RH1T3CT0R7:fix/4186

Conversation

@4RH1T3CT0R7

Copy link
Copy Markdown

Tab embeds its root views.Node, so tab:ID() in Lua ends up calling Node.ID(). That method returns 0 for any node that has children, and once a tab contains a split its root is no longer a leaf. A plugin that keys anything on the tab id loses track of the tab the moment the user splits it, which is what #4186 reports.

Tab now carries its own id, taken from the root node when the tab is created, and ID() returns that. For an unsplit tab the value is the same as before, it just no longer changes after a split. A small test in internal/action covers the split case and checks that two tabs get distinct ids.

Fixes #4186

`Tab` embeds its root `views.Node`, so `tab:ID()` from Lua resolved to
`Node.ID()`, which returns 0 for any node that has children. As soon as
a tab contained a split its root stopped being a leaf and the id was
gone.

Give `Tab` its own id, taken from the root node when the tab is created,
so it stays the same after splitting. An unsplit tab reports the same
value as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tabs with splits return ID() = 0 (in Lua)

1 participant