Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add terminal observer API #13402

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

tsmaeder
Copy link
Contributor

@tsmaeder tsmaeder commented Feb 20, 2024

What it does

This is a draft PR for feedback on #13085

How to test

The attached theia plugin adds two commands: "Register Observer" and "Remove Observer". The first one allows to register a terminal observer with a given name, regular expression to match and a number of lines to match. The second command unregisters obeservers registered before by name.

The registered observers write the matched strings to the Theia back end log.

Follow-ups

Review checklist

Reminder for reviewers

@tsmaeder tsmaeder marked this pull request as draft February 21, 2024 13:59
@tsmaeder tsmaeder requested a review from msujew February 21, 2024 13:59
@tsmaeder
Copy link
Contributor Author

Here's the plugins

terminalobserver.zip

and here's the source:

terminalobserver.zip

@tsmaeder tsmaeder marked this pull request as ready for review February 28, 2024 15:44
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
@JonasHelming JonasHelming requested review from martin-fleck-at and removed request for msujew March 5, 2024 12:36
@tsmaeder tsmaeder requested a review from jonah-iden March 6, 2024 09:27
Copy link
Contributor

@jonah-iden jonah-iden left a comment

Choose a reason for hiding this comment

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

All in all seems to work great and code looks good to me.

just something i found a little weird but i don't know if its a problem. Following console output

gitpod /workspace/theia (13085_terminal_observer) $ testx
bash: testx: command not found
gitpod /workspace/theia (13085_terminal_observer) $ 

having an observer with .*testx.* for one line only prints

["gitpod /workspace/theia (13085_terminal_observer) $ testx                                                                     "]```

But with two lines it prints

["gitpod /workspace/theia (13085_terminal_observer) $ testx                                                                     "]
["bash: testx: command not found                                                                                                "]
["bash: testx: command not found                                                                                                "]

I would have expected for one line it would print the command not found once and for two lines maybe twice because one for when the output is first printed and one when the input prompt is back again or none for 1 line and once for 2 lines

@tsmaeder
Copy link
Contributor Author

All in all seems to work great and code looks good to me.

just something i found a little weird but i don't know if its a problem. Following console output

gitpod /workspace/theia (13085_terminal_observer) $ testx
bash: testx: command not found
gitpod /workspace/theia (13085_terminal_observer) $ 

having an observer with .*testx.* for one line only prints

["gitpod /workspace/theia (13085_terminal_observer) $ testx                                                                     "]```

But with two lines it prints

["gitpod /workspace/theia (13085_terminal_observer) $ testx                                                                     "]
["bash: testx: command not found                                                                                                "]
["bash: testx: command not found                                                                                                "]

I would have expected for one line it would print the command not found once and for two lines maybe twice because one for when the output is first printed and one when the input prompt is back again or none for 1 line and once for 2 lines

No, I think this is correct: the code is matching against the last n lines each time text is added to the terminal. If you type "testx", the matching will be done basically on every character you type. Since the previous line already matches .*testx.*, the listener will be triggered multiple times as you type.

@tsmaeder tsmaeder merged commit cffeeac into eclipse-theia:master Mar 21, 2024
14 checks passed
@jfaltermeier jfaltermeier added this to the 1.48.0 milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants