question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

5.1.1 : omitted indentation when pasting with the editor

See original GitHub issue

Installed 5.1.1 and reset to factory defaults. Then, I created a small function:

def f():
    x = 1
    y = 2

I wanted to add another assignment just after x = 1. So, I copied that entire line and pasted it. This was the result:

def f():
    x = 1
x = 1
    y = 2

Uninstalled 5.1.1 and installed 5.0.5. Then, I reset to factory defaults and created the same small function:

def f():
    x = 1
    y = 2

Then, I copied that entire x = 1 line and pasted it. This was the result:

def f():
    x = 1
    x = 1
    y = 2

IMO, the 5.0.5 editor behaved correctly but the 5.1.1 editor neglected to paste in the indentation.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Aug 5, 2021

@impact27, if the first line a user is trying to paste contains some indentation, I think we should preserve it, and adjust the indentation of all other lines according to that.

What do you think?

0reactions
sphhcommented, Aug 13, 2021

I solved this by changing the statements between https://github.com/spyder-ide/spyder/blob/48065f03dc7edb04093425032f9c69f0a26dda25/spyder/plugins/editor/widgets/codeeditor.py#L2836 and (including) https://github.com/spyder-ide/spyder/blob/48065f03dc7edb04093425032f9c69f0a26dda25/spyder/plugins/editor/widgets/codeeditor.py#L2839 to

            indentations = [
                self.get_line_indentation(line)
                for line in remaining_lines if line.strip() != ""]
            if indentations:
                max_dedent = min(indentations)
                lines_adjustment = max(lines_adjustment, -max_dedent)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Indenting and Turning Off Auto Indent When Pasting Text Into Vi
In this tutorial, we look at indenting and ways to preserve proper indentation when pasting text in the Vi editor. First, we briefly...
Read more >
Wrong indentation after copy-paste : PY-18522
We're looking into the problem, but as a temporary workaround you can disable Editor | General | Smart Keys | Smart indent pasted...
Read more >
Turning off auto indent when pasting text into vim
To turn off autoindent when you paste code, there's a special "paste" mode. Type :set paste. Then paste your code. Note that the...
Read more >
Leading spaces are not preserved when pasting text - TeX
Indent and Unindent Automatically: re-indents text automatically to match the context. ... Go to Options > Configure TeXstudio > Editor.
Read more >
Experiencing an odd copy + paste block of code issue with ...
Steps to Reproduce: Copy block of code with indentations correct. Go to new line and indent to where you want the paste code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found