Khan / Khan/live-editor

print doesn't output anything until println has been written after it

Open
#574 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
776
Forks
180
PR merge metrics
No merged PRs in 30d

Description

### Summary

When typing:
`print("test");`
then nothing shows up in the live editors console.

To get the print command to output anything, add a println command after the print command.
for example:
`println("test2");`
### Expected Behavior

When writing a print command, then it should output to the live editors console once, without adding a new line.
### Actual behavior

Nothing happens.

There's another strange behavior:
When the print command doesn't output anything, then it seems to be stored somewhere, because if the `print("test");` is written once and then commented and uncommented a couple of times with the hotkey: (ctrl + /).
Then if `println("test2");` is written below the print command, now the print command gets written to the console several times, the steps are explained below.
### Steps to Reproduce
1. type: `print("test");`
nothing happens
2. type: `println("test2");`

The live editors console now opens and shows the following:

```
testtesttest
test2
```

For some reason the print command is written 3 times.
If the println command is commented and uncommented once, then the print command is written twice:

```
testtest
test2
```

To see that the print commands output is stored somewhere until the println command is called.

Comment out the second line:

```
print("test");
// println("test2");
```

Now comment and uncomment the first line 5 times (hotkey: ctrl + /):

```
// print("test");
// println("test2");
```

Finally if the first line is commented, then uncomment it, now uncomment the second line,
and the console shows:

```
testtesttesttesttesttesttest
test2
```
### Environment

OS: Windows 7 Home Premium 64 bit
Browser: Google Chrome Version 49.0.2623.112 m

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue in the live editor console with print("test"); and println("test2");, including repeated comment and uncomment actions. Trace how the editor executes changed code and buffers console output; done means print appears once without println and comment toggling does not duplicate it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.