atom-community / atom-community/atom-script

`Script: Run` doesn't behave as expected after you highlight and comment-out lines of code

Open
#1,510 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
730
Forks
264
PR merge metrics
No merged PRs in 30d

Description

OS: Ubuntu 16.04 LTS
Atom version: 1.23.1 x 64
Python version: Python 3.6.3, Python 2.7.12, and Python 3.5.2 (tested on all three)

I am experiencing an issue with the `Script: Run` command. It must be sending the wrong text to Python. Here are the steps to reproduce the problem:

**Step 1.** input the following text into a `.py` file:
```
x = 'hello'
print(x)
```
**Step 2.** Hit Ctrl+Shift+B to run `Script: Run` and the correct output is displayed:
```
hello
[Finished in 0.046s]
```
**Step 3.** Using your cursor, highlight the first line of the code, namely `x = 'hello'`.

**Step 4** Hit Ctrl+/ to comment it out. Remember: you must highlight the line using your cursor first. If you simply hit Ctrl+/ on th

**Step 5.** Hit Ctrl+Shift+B to run `Script: Run` and the following **incorrect** output is displayed:
```
[Finished in 0.065s]
```
Since we have removed the x's definition, python should display a `NameError`, but it does not.

**Step 6.** Now try adding a few newlines to the bottom of the file and hit Ctrl+Shift+B to run `Script: Run` and now the correct output is displayed:

```
Traceback (most recent call last):
File "/home/test/test.py", line 2, in
print(x)
NameError: name 'x' is not defined
[Finished in 0.078s]
```
If Step 3 is skipped, and you simply hit Ctrl+/ while on the first line of code, the issue does not occur.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.