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.

Incorrect indentation after string literals containing escaped characters

See original GitHub issue

Steps to reproduce:

  1. Type string with ‘\n’ in it, press Enter.
a = '\n'

Same for double quotes.

Expected behaviour

a = '\n'
<--- cursor should be here

Actual behaviour

a = '\n'
    <--- cursor is here

Environment data

  • VS Code version: 1.30.2
  • Extension version (available under the Extensions sidebar): 2019.1.0
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7
  • Type of virtual environment used: N/A
  • Relevant/affected Python packages and their versions: none

Logs

Console:

Starting Jedi Python language engine.

Linter 'pylint' is not installed. Please install it or select another linter".
Error: Module 'pylint' not installed.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
caudate-juliecommented, Jan 31, 2019

I am not familiar with the code, but it may be this string: https://github.com/Microsoft/vscode-python/blob/c23603c9b7a3dbb805e8339a2d7cf01bb7327b34/src/client/extension.ts#L176 since regex doesn’t include end of line.

0reactions
ericsnowcurrentlycommented, Jul 9, 2019

I’ve verified that the following indent/dedent properly:

a = '\n'
# cursor here

a = 1 + \
    # cursor here
Read more comments on GitHub >

github_iconTop Results From Across the Web

Proper indentation for multiline strings? - python
Docstrings are treated specially: any indent of the first line is removed; the smallest common indent taken over all other non-blank lines is...
Read more >
[Review] SE-0168: Multi-Line String Literals - Swift Forums
For instance, it's good practice to put either a space, or a newline and indentation, between array and dictionary literal delimiters or curly...
Read more >
Multiline template strings that don't break indentation
Solution 1: Ignore all space and tab characters following a newline until the first non-space or tab character. The problem with this is...
Read more >
Appendix: YAML Techniques - Helm
You can escape line breaks with \n . Single-quoted strings are "literal" strings, and do not use the \ to escape characters. The...
Read more >
2. Lexical analysis — Python 3.11.1 documentation
A comment starts with a hash character ( # ) that is not part of a string literal, and ends at the end...
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