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

Working with electric-pair-mode #435

Open
Hamzehn opened this issue Nov 6, 2021 · 0 comments
Open

Working with electric-pair-mode #435

Hamzehn opened this issue Nov 6, 2021 · 0 comments

Comments

@Hamzehn
Copy link

Hamzehn commented Nov 6, 2021

I have electric-pair-mode turned on by default, and I noticed that when I'm using the python function docstring snippets, every time I define a default string value for a parameter the snippet expansion duplicates the entire argument list.

For example:

def foo(param1, param2=None, param3="bar"):

Produces the following output:

def foo(param1, param2=None, param3="bar"):
 """
 Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default "bar")Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default ")
 """

Notice how the extra text ends at the double quote.

The extra text gets inserted the moment I type the opening double quote and electric pair mode automatically adds the closing one. The cursor at the time will be on the opening quote. If I copy/paste a double quote pair in one shot, this doesn't happen.

This behavior continues by adding extra text above the old extra one if I continue adding parameters that have electric pairs like that. For example if I add a 4th parameter:

def foo(param1, param2=None, param3="bar", param4="baz"):
 """
 Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default "bar")
 param4 -- (default "baz")Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default "bar")
 param4 -- (default ")Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default ")
 """

Notice how it updates the arguments list correctly at the top, but it keeps adding extra text below while not removing the old one.

The same thing happens if I enter any of the other pair symbols (like '(', '[', '{' etc.). For example, if I add a 5th parameter that has a default list value (I know, not best practice in Python but just for illustration purposes):

def foo(param1, param2=None, param3="bar", param4="baz", param5=[1, 2]):
 """
 Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default "bar")
 param4 -- (default "baz")
 param5 -- (default [1)
 2]     -- Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default "bar")
 param4 -- (default "baz")
 param5 -- (default [)Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default "bar")
 param4 -- (default ")Keyword Arguments:
 param1 -- 
 param2 -- (default None)
 param3 -- (default ")
 """

Any idea how I can resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant