Comments (2)
@b0o could you provide a repro, please? 🙏
from nui-components.nvim.
The issue depends on the timing of when the signal value is updated. Specifically, it seems to happen if the signal is updated in the middle of a render?
local n = require 'nui-components'
local renderer = n.create_renderer {
width = math.min(vim.o.columns, 64),
height = math.min(vim.o.lines, 20),
}
local signal = n.create_signal {
stdout = '',
stderr = '',
}
renderer:render(
--
n.rows(
n.paragraph {
is_focusable = false,
-- Side note: Although we are mapping over the stdout signal value, the function is called when
-- either stdout or stderr changes.
-- In fact, it seems we can map over any signal field, even if it doesn't exist, like signal.foobar:map(...)
-- IMO, we should be able to just do signal:map() instead of needing to index a specific field
lines = signal.stdout:map(function()
local val = signal:get_value()
return {
n.line(n.text('Stdout: ', 'Keyword'), val.stdout),
n.line(n.text('Stderr: ', 'Keyword'), val.stderr),
}
end),
},
n.gap(1),
n.button {
label = ' Run Command ',
autofocus = true,
on_press = function()
vim.fn.jobstart('for i in {1..10}; do sleep 0.1; echo "stdout: $i"; echo "stderr: $i" >&2; done', {
on_stdout = function(_, data, _)
if data and data[1] and data[1] ~= '' then
signal.stdout = data[1]
end
end,
on_stderr = function(_, data, _)
if data and data[1] and data[1] ~= '' then
signal.stderr = data[1]
end
end,
})
end,
}
)
)
You might need to press the Run Command
button a few times to see the error.
from nui-components.nvim.
Related Issues (15)
- Basic question how to run intro.lua HOT 2
- Ability to set window-local highlights HOT 1
- Link to the nvim-spectre example is broken HOT 1
- Feature: Support `max_lines` prop for paragraph component
- Feature: add `signal:map()` method HOT 2
- Adding a border to a paragraph causes extra line breaks
- Possibilility of dynamic shrink window height? HOT 5
- Signal values are not being unsubscribed on component unmount
- All SignalValues emit when a single value is updated
- bug: n.select `on_select` field returns nil when node clearly exists HOT 2
- bug: `renderer:render()` will render blank box when called a 2nd time from a function HOT 2
- bug: `Tree` component does not properly set CursorLine highlight to line in window HOT 3
- Wouldnt it be better to use icons for checkbox? [Suggestion] HOT 2
- `Select` not showing proper amount of options on different renders HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nui-components.nvim.