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

RTT Terminals won't show up #87

Closed
hyx0329 opened this issue Mar 12, 2024 · 3 comments · Fixed by #88
Closed

RTT Terminals won't show up #87

hyx0329 opened this issue Mar 12, 2024 · 3 comments · Fixed by #88

Comments

@hyx0329
Copy link
Contributor

hyx0329 commented Mar 12, 2024

Extension version: 0.23.0
VSCode version:

  • Code OSS: 1.87.1
  • VSCodium: 1.87.1

No RTT terminal is opened even when RTT is configured correctly.

It seems there's a mistake in createRttTerminal:

vscode/src/extension.ts

Lines 200 to 205 in 23f7b8a

for (let index in this.rttTerminals) {
var [formerChannelNumber, , ,] = this.rttTerminals[index];
if (formerChannelNumber === channelNumber) {
this.rttTerminals.splice(+index, 1);
break;
}

The index will be a string('distinct') rather than a number, while getting element of a list(rttTerminals) requires a number. This causes an exception raised.

I'm not familiar with TS but I've tested the following patch:

diff --git a/src/extension.ts b/src/extension.ts
index ca793ef..0ea8c78 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -197,7 +197,7 @@ class ProbeRSDebugAdapterServerDescriptorFactory implements vscode.DebugAdapterD
                     name: channelName,
                     pty: channelPty,
                 };
-                for (let index in this.rttTerminals) {
+                for (let index = 0; index < this.rttTerminals.length; index++) {
                     var [formerChannelNumber, , ,] = this.rttTerminals[index];
                     if (formerChannelNumber === channelNumber) {
                         this.rttTerminals.splice(+index, 1);

Then the RTT terminal comes up.

@Yatekii
Copy link
Member

Yatekii commented Mar 12, 2024

Hmm the two should def. not behave differently :/

@hyx0329
Copy link
Contributor Author

hyx0329 commented Mar 12, 2024

Let me see... Oh! It seems let ... in will also iterate over the properties of the object. Look at this:
Screenshot from 2024-03-12 20-24-00
index is the string distinct XD

@noppej
Copy link
Contributor

noppej commented Mar 12, 2024

@hyx0329 This is a good catch, and reading about it a bit more about TS handling lists, it kinda makes sense. I personally think Typescript should be less 'subtle' about this.

Do you want to PR a fix, or would you prefer one of us to just apply your patch?

@noppej noppej linked a pull request Mar 12, 2024 that will close this issue
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 a pull request may close this issue.

3 participants