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

Python: smartquotes with f-strings #5063

Closed
jasonmotha opened this issue Feb 16, 2023 · 5 comments
Closed

Python: smartquotes with f-strings #5063

jasonmotha opened this issue Feb 16, 2023 · 5 comments

Comments

@jasonmotha
Copy link

Describe the bug

When using python in an editor typing print(f"{test}") results in a smart quote being added on the second quote but not the first.

Expected Behavior

I'd expect a smartquote to be added on the first quote.

Current Behavior

A smartquote is added when you are closing the quote on the f-string.

Reproduction Steps

typing print(f"{test}")

Or any f-string with a variable.

Possible Solution

Detecting parameters that create f-strings

Additional Information/Context

This might also be a problem for raw strings in python.

Ace Version / Browser / OS / Keyboard layout

I tested this on the live version too https://ace.c9.io/build/kitchen-sink.html -- browser is firefox, also reproduced in chrome.

@InspiredGuy
Copy link
Contributor

Thanks for the the report! The issue seems to be that current behaviour, used for the python mode, prevents second quote to be added if there is a word before the first quote - https://github.com/ajaxorg/ace/blob/master/src/mode/behaviour/cstyle.js#L264. Creating a new behaviour for Python, which would add a check for that syntax-specific symbol present in front of the first quote to prevent returning null instantly, might fix this issue. The check in the new behaviour could be something like if ((isWordBefore && wordBefore !== 'f') || isWordAfter).

@alnmrata
Copy link

Uploading 529896da-673d-d2ce-12fc-82916146c2d1-main.mp4 …

@alnmrata
Copy link

[@alnmrata

@alnmrata
Copy link

Uploading 529896da-673d-d2ce-12fc-82916146c2d1-main.mp4 …

InspiredGuy pushed a commit that referenced this issue Mar 16, 2023
* add new behaviour option to determine specific prefixes for quote insertion

* make quotes check more generic; add auto quote insertion for javascript (backtick)

* change cstyle behaviours option to more suitable

* add type definition for Mode; move `$pairQuotesAfter` from options to mode property

Issue #5063
@andrewnester
Copy link
Contributor

Released in 1.16.0

akoreman pushed a commit to akoreman/ace that referenced this issue Mar 19, 2023
…rg#5067)

* add new behaviour option to determine specific prefixes for quote insertion

* make quotes check more generic; add auto quote insertion for javascript (backtick)

* change cstyle behaviours option to more suitable

* add type definition for Mode; move `$pairQuotesAfter` from options to mode property

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

No branches or pull requests

4 participants