MrPicklePinosaur / shrs

The rusty shell toolkit for hackers
https://mrpicklepinosaur.github.io/shrs/
Apache License 2.0
304 stars 24 forks source link

[Feature]: Simplify line context #412

Closed MrPicklePinosaur closed 5 months ago

MrPicklePinosaur commented 5 months ago

What would you like to see added?

Previously since shrs_line and shrs_core were kept separate, there was a lot of spaghetti state flow. In particular, we passed in Shell, Runtime and Context to line so line could mutate/read shell state for the purposes of keybindings, theme, triggering hooks etc. However, this breaks down when we would like to access line state from shell, for example modifying the contents of the line from a hook / keybinding / builtin.

Overall all this state flow is very messy. Take a look at reedline crate to see how they manage passing state between the readline and nushell itself.

An easy way to make things a bit cleaner is to tackle LineCtx first. Currently it contains Shell, Runtime, and Context all bundled together along with state the line uses. We should at least separate out the Line specific stuff and create a new 'bundle struct' that just holds Shell, Runtime, Context and LineCtx to reduce the number of arguments we are passing around

MrPicklePinosaur commented 5 months ago

Cleaned up LineCtx struct in #417, this still needs more work though