You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminal should provide API to notify data cleaned by control sequences #29840
I noticed that the terminal no sends Operating System Commands (OSC) like setting the window title. Right now the task runner filters them but this gets more and more complex and I am actually not an expert with this. So I would like to request that the terminal provides API to notify data without control sequences. Currently I used these two regular expressions to filter them:
Various control sequences can do a whole lot of stuff, so where is the best place to gather this data? It might be worth seeing if adding listeners to addChar and lineFeed will give what you need.
How do this efficiently. Because a lot of data can stream through the terminal, we should probably only enable this when it's explicitly requested (ie. only fire the event if something is listening). It should probably also be batched.
From a problem matcher point of view it would be enough sending the line. We could sent it when a linefeed is added. Then there is still the problem of a line content changing. We once discussed the idea of a line identifier to signal that. I agree that sending single characters might not be a smart idea in terms of performance.
If it's just on line feed then many characters could go missing, eg. "abc" "def" would result in "def" only. Maybe this is not something we care about, but it could lead to some obscure bugs if people relied on this new API.
This is a good example why something like a line model would be helpful: #22065 (comment).
After looking into the issue it looks like that pester constantly 'repaints' the whole screen hence the terminal sending the same line onData over and over again. For me it is very hard to tell whether I have seen that line and whether I have processed it already (the same content). What would be cool if the terminal could provide a line model where is line has an id (number) and changes are signaled on that model instead of sending raw data.
Dirk Bäumer (@dbaeumer) I actually added an ID concept to the buffer when doing the selection stuff (xtermjs/xterm.js@65256c8) but I ended up not needing it and pulling it out, instead the selection listens to when the buffer is trimmed and adjusts the indexes of its own model.
It really didn't feel very good adding it as it introduced much more complexity to the already complex circular list and added the overhead of an addition object for every entry - which is a lot when you need to create tens of thousands of these things in an instant. There were other issues that come up with this like IDs being interleaved due to programs having the ability to delete/insert lines so there's no way I could think of to optimize it nicely, leading to a slower, more memory hungry terminal.
It would probably be easier and more performant to just deduplicate these errors on your end. For example you could record a hash for current problems and check it before adding new problems, or perhaps even better, record the raw terminal line of the error so you don't need to parse it again for duplicate problems.
I implemented the deduplicate yesterday but it feels like a hack on my side :-) I need to create a unique key for something that doesn't necessarily have one. I still think having a line bassed model comparable to what the editor exposes would be a nice thing. Me giving the raw data is comparable to the editor signaling raw cursor moves and text changes. Instead I get a nice model with text edit events. And I am not interested in color information like I am not interested in this on an editor buffer.
Just for the record. I can not filter on the line itself from the terminal without knowing if I have parsed that line already. Matchers are multiline aware and there could be two equal lines in one output on purpose since they difference is made by a line above. Me knowing this is implementing a line model on top of it :-)
Dirk Bäumer (@dbaeumer) isn't the point of programs rewriting lines that the lines do change and that they may need to be reparsed?
Here's one idea that might work for both of us: exposing some data stream you can listen to as in the original comment, but only ever pushing data if it's on the last line in the terminal. Would this cover your use case? For the PS case #22065 (comment) you would get multiple lines for the last line but maybe this could be more clever somehow in recording when the cursor moves and only reporting the line a single time (not by using IDs but by only reporting once after a lineFeed call inserts a new line.
Daniel Imms (@Tyriar) thanks a lot for the detailed explanation. Having solution 2 will for sure make my life easier and will not make things worse on my end. Regarding option 3: I am not interested in the view model since I need lines unwrapped. The line model is what would work best for me assuming that the line model doesn't have any \n in there to make lines visually wrap .
Daniel Imms (@Tyriar) I will be out on vacation until 2. August. I think we need to address this sooner than later since we can't assume that problems always fit onto one line.
An interims solution could be as follows: can we introduce a custom control sequence (e.g. a operating system control sequence) that describes the new lines inserted to wrap the text. I could then filter them on my end since I would be able to distinguish them from normal newline. Would this be something you can add in July then I would catchup with it for the July build ?
Activity
Tyriar commentedon Jun 29, 2017
There are two unknowns to me right now with this:
addCharandlineFeedwill give what you need.PR welcome upstream.
dbaeumer commentedon Jun 30, 2017
From a problem matcher point of view it would be enough sending the line. We could sent it when a linefeed is added. Then there is still the problem of a line content changing. We once discussed the idea of a line identifier to signal that. I agree that sending single characters might not be a smart idea in terms of performance.
Tyriar commentedon Jun 30, 2017
If it's just on line feed then many characters could go missing, eg. "abc" "def" would result in "def" only. Maybe this is not something we care about, but it could lead to some obscure bugs if people relied on this new API.
dbaeumer commentedon Jul 6, 2017
This is a good example why something like a line model would be helpful: #22065 (comment).
After looking into the issue it looks like that pester constantly 'repaints' the whole screen hence the terminal sending the same line onData over and over again. For me it is very hard to tell whether I have seen that line and whether I have processed it already (the same content). What would be cool if the terminal could provide a line model where is line has an id (number) and changes are signaled on that model instead of sending raw data.
Tyriar commentedon Jul 6, 2017
Dirk Bäumer (@dbaeumer) I actually added an ID concept to the buffer when doing the selection stuff (xtermjs/xterm.js@65256c8) but I ended up not needing it and pulling it out, instead the selection listens to when the buffer is trimmed and adjusts the indexes of its own model.
It really didn't feel very good adding it as it introduced much more complexity to the already complex circular list and added the overhead of an addition object for every entry - which is a lot when you need to create tens of thousands of these things in an instant. There were other issues that come up with this like IDs being interleaved due to programs having the ability to delete/insert lines so there's no way I could think of to optimize it nicely, leading to a slower, more memory hungry terminal.
It would probably be easier and more performant to just deduplicate these errors on your end. For example you could record a hash for current problems and check it before adding new problems, or perhaps even better, record the raw terminal line of the error so you don't need to parse it again for duplicate problems.
dbaeumer commentedon Jul 7, 2017
I implemented the deduplicate yesterday but it feels like a hack on my side :-) I need to create a unique key for something that doesn't necessarily have one. I still think having a line bassed model comparable to what the editor exposes would be a nice thing. Me giving the raw data is comparable to the editor signaling raw cursor moves and text changes. Instead I get a nice model with text edit events. And I am not interested in color information like I am not interested in this on an editor buffer.
dbaeumer commentedon Jul 7, 2017
Just for the record. I can not filter on the line itself from the terminal without knowing if I have parsed that line already. Matchers are multiline aware and there could be two equal lines in one output on purpose since they difference is made by a line above. Me knowing this is implementing a line model on top of it :-)
Tyriar commentedon Jul 7, 2017
Dirk Bäumer (@dbaeumer) isn't the point of programs rewriting lines that the lines do change and that they may need to be reparsed?
Here's one idea that might work for both of us: exposing some data stream you can listen to as in the original comment, but only ever pushing data if it's on the last line in the terminal. Would this cover your use case? For the PS case #22065 (comment) you would get multiple lines for the last line but maybe this could be more clever somehow in recording when the cursor moves and only reporting the line a single time (not by using IDs but by only reporting once after a
lineFeedcall inserts a new line.2 remaining items
dbaeumer commentedon Jul 12, 2017
Daniel Imms (@Tyriar) thanks a lot for the detailed explanation. Having solution 2 will for sure make my life easier and will not make things worse on my end. Regarding option 3: I am not interested in the view model since I need lines unwrapped. The line model is what would work best for me assuming that the line model doesn't have any
\nin there to make lines visually wrap .Tyriar commentedon Jul 12, 2017
Dirk Bäumer (@dbaeumer) option 3 including reflow xtermjs/xterm.js#644 (comment) is required in order to get unwrapped lines
Not sure when I'll have time to work on this, pretty swamped atm. It might be a good opportunity to collaborate if this is high priority for you?
dbaeumer commentedon Jul 13, 2017
Daniel Imms (@Tyriar) I will be out on vacation until 2. August. I think we need to address this sooner than later since we can't assume that problems always fit onto one line.
An interims solution could be as follows: can we introduce a custom control sequence (e.g. a operating system control sequence) that describes the new lines inserted to wrap the text. I could then filter them on my end since I would be able to distinguish them from normal newline. Would this be something you can add in July then I would catchup with it for the July build ?
Tyriar commentedon Jul 13, 2017
Dirk Bäumer (@dbaeumer) I actually expect you to get the unwrapped lines currently, xterm.js just wraps the lines when they are going to overflow https://github.com/sourcelair/xterm.js/blob/2ebc926f4e438c77c4da702b14f82f46424120a8/src/InputHandler.ts#L55, that's the only wrapping it knows about.
On Windows though I'm not sure rows are ever marked to be wrapped (not 100% sure), at least on PowerShell. This is just how winpty works.
Provide an ITerminalInstance.onLineData internal API
Send last line terminal data when process exits
Send last line terminal data when process exits
Provide an ITerminalInstance.onLineData internal API