atom-community / atom-community/ide-python

Automatic code formatting duplicates lines and blocks of code

未关闭
#384 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
upstream issue
主要语言
JavaScript
星标
238
派生
40
PR 合并指标
30 天内没有已合并 PR

描述

There seems to be a bug in automatic code formatting. The bug is triggered by opening the same code file into multiple tabs in separate panes. Having two tabs (of the same file) will cause the bug to occur once, three tabs will cause it to repeat twice, and so on.

I have been using the `ide-python` package only for a couple days, so I don't know about the specifics. This bug is present in both versions `1.9.4` and `1.9.5` at least. I turned off all checkboxes in the module's settings and restarted Atom, but this bug will still persist. I am using the "format on save" option.

Also, the file status is "modified" again after I **save** the file and automatic formatting is applied, so the file has to be manually saved twice. I don't think it should be like this.

### Example 1

**Original code**

```python
def foo():
pass

def bar():
pass
```

**Result after automating formatting**

```python
def foo():
pass

def bar():
pass
pass

```

Here the keyword `pass` is duplicated inside function `bar`.

### Example 2

**Original code**

```python
def foo():
pass
def bar():
pass

```

**Result after automating formatting**

```python
def foo():
pass

def bar():
pass
def bar():
pass

```

Here the whole function block for `bar` is duplicated. Formatting is also messed up.

贡献指南

打开贡献指南

调研方向

首先,在 Atom 中使用 ide-python 1.9.4 或 1.9.5,启用保存时格式化,并在多个窗格中打开同一个 Python 文件,以重现该问题。跟踪自动格式化和保存路径,以确定为什么每个额外的标签页都会复制内容;当格式化不再复制行或代码块,并且文件在保存一次后不再保持修改状态时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, python
领域
tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。