Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad insertion of triple quotes around multiline selection if starting at end of first line, breaking redo #1716

Closed
jskm opened this issue Aug 23, 2021 · 5 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@jskm
Copy link

jskm commented Aug 23, 2021

Environment data

  • Language Server version: 2021.8.2
  • OS and version: win32 x64
  • Python version: Python 3.8.10 64-bit

Expected behaviour

"""
multiple lines
of code
"""

Actual behaviour

""""""
multiple lines
of code
"""

Details and steps to reproduce

  1. Start with a sample text:
multiline| <- cursor here
test
  1. Select downward.
  2. Type triple quote.

Result:

multiline"""|""" <- cursor moves from line below to pipe character position
test"""

Unwanted closing triple quotes are added on the first line, with cursor in the middle.

This also breaks redo:

  1. Delete the extra triple quotes. Type something else.
multiline""" Hello world!
test"""
  1. Undo until before the triple quotes were completed:
multiline""
test""
  1. Redo. As soon as the third quote returns, the completion is triggered again, and you lose the rest of the redo stack.
multiline""""""
test"""

More abnormal behavior:

5b. Undo a few extra steps, and then hold the redo command. According to the repeat rate, you might get another command or two in before the closing triple quotes appear:

multiline"""""" H
test"""

The situation that prompted this report looked like this: (I don't know how to replicate it)

"""
mult|"""iple lines (<- cursor at pipe character)
of code
"""
@jakebailey
Copy link
Member

Thanks, I can reproduce this. I think the fix for now will be to disable this custom code when in multi-line editing mode.

triplequotebug1

@jakebailey jakebailey added the bug Something isn't working label Aug 23, 2021
@github-actions github-actions bot removed the triage label Aug 23, 2021
@jskm
Copy link
Author

jskm commented Aug 24, 2021

Ah, I didn't notice the same effect occurred with multiple cursors. Does surrounding a selection with quotes also fall under multi-line editing, though? (with a single cursor, shift-down, then typing quotes)

@jakebailey
Copy link
Member

When you actually make a selection and start typing quotes, VS Code takes over and will insert them on both sides of the selection, so my fix will cover that as well.

In both cases, typing triple quotes on more than one line will cause issues tokenizing the file (as we need to know if it's okay to close the quotes based on the rest of the file), so it's not generally possible to do so with our current implementation.

VS Code has built-in support for closing regular strings, but that logic relies on it being limited to a single line, so it's a bit hard to emulate.

@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Aug 24, 2021
@jakebailey
Copy link
Member

This should be fixed in the next release, for both non-empty selections and multi-line selections.

@heejaechang
Copy link
Contributor

the fix is in 2021.8.3 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants