notepad-plus-plus / notepad-plus-plus/notepad-plus-plus

Auto-insert of quotes doesn't work with Python f-strings

Open
#10,096 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
29.4k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

Description of the Issue

I turned on auto-insert of parenthesis, single and double quotes. Then I start a very common Python command:
print(f'|)
where | is the cursor position and the closing parenthesis was auto-inserted. When I type the opening quote, either single or double, Npp does not auto-insert the second, closing quote. When the string has no 'f' before, the auto-insert works fine.
The problem also happens when using an f-string outside parenthesis:
s = f'
However, there is a workaround for this case: in the Auto-insert setting box, use the matched pairs for quotes, and now the auto-insert works for the last case, but not for the former print(f') with the auto-inserted closing parenthesis.

Steps to Reproduce the Issue
  1. In Settings, Preferences, Auto-Completion, Auto-insert box, check the boxes for (), [], {}, " " and ' '. Close.
  2. Type: print(f') with either single or double quotes. The closing parenthesis is automatically inserted.
Expected Behavior

The closing quote is automatically inserted.

Actual Behavior

Only the opening quote is shown. The closing quote is not inserted.

Debug Information

Notepad++ v8.1 (32-bit)
Build time : Jun 17 2021 - 01:52:11
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Home (64-bit)
OS Version : 2009
OS Build : 19043.1052
Current ANSI codepage : 1252
Plugins : mimeTools.dll NppConverter.dll NppExport.dll

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue through Settings > Preferences > Auto-Completion > Auto-insert using the reported print(f') and s = f' cases. Compare quote insertion with and without the f-string prefix, including the matched-pairs workaround. Done means closing quotes are inserted in both reported contexts without regressing ordinary quote insertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
desktop, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.