8000 output: fix io.Reader when used with LineMap by bobheadxi · Pull Request #37 · sourcegraph/run · GitHub
[go: up one dir, main page]

Skip to content

Conversation

8000
@bobheadxi
Copy link
Member
@bobheadxi bobheadxi commented May 31, 2022

I noticed LineMaps are not applied in my "fix" for io.Reader in which I kind of completely forgot about LineMaps.

  1. Fix io.Reader + line maps
  2. More robust tests for various line map scenarios

The implementation is not ideal, there are quite a few layers of buffering. I explored incremental reading of the command output, but it's super hard (impossible?) without lookahead, since we never know when the line has really ended, and LineMap depends on full lines

I wonder if we can lift line map assignment out of output, and into command. Then we can perhaps deal purely with mapped output

tldr I might have overcomplicated things 😂😂😂

@bobheadxi bobheadxi requested a review from michaellzc as a code owner May 31, 2022 08:19
@bobheadxi bobheadxi changed the title output: fix output: fix io.Reader again May 31, 2022
@bobheadxi bobheadxi changed the title output: fix io.Reader again output: fix io.Reader when used with LineMap May 31, 2022
@bobheadxi bobheadxi requested a review from a team May 31, 2022 08:19
Copy link
Contributor
@jhchabran jhchabran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this is getting complicated. But that's fine as we're learning as we go through. Trying to see how we can refactor all of it during the offsite would be a cool activity 😊

return dst.Write(bytes.ReplaceAll(line, []byte("world"), []byte("jh")))
})
},
expect: "goodbye jh",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, it's good morning here 😆 🤗

Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr>
@bobheadxi bobheadxi force-pushed the io-read-is-wrong-again branch from 6f038bd to dbbf2bd Compare May 31, 2022 18:17
@bobheadxi bobheadxi merged commit 2ddd06d into main May 31, 2022
@bobheadxi bobheadxi deleted the io-read-is-wrong-again branch May 31, 2022 18:17
@bobheadxi
Copy link
Member Author

Trying to see how we can refactor all of it during the offsite would be a cool activity 😊

Sounds like a great exercise! 😁

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.

3 participants

0