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

Opening a quote (") automatically enters a closing quote (") automatically but if I also enter a close quotation, I end up with 2 quotation close #982

Closed
saurabh2804 opened this Issue Aug 3, 2018 · 14 comments

Comments

Projects
None yet
3 participants
@saurabh2804

saurabh2804 commented Aug 3, 2018

Expected behaviour

If close quotation is entered by QOwnNotes, then if I enter the same myself, it should just replace the entered one with the on I have entered or simply place the cursor after the close quote. Now instead of closing the quote myself("some text"), I have to move the cursor to the right of the close quote with the arrow key which beats the purpose of having the quotation close entered automatically

Actual behaviour

Opening a quote (") automatically enters a closing quote (") automatically but if I also enter a close quotation, I end up with 2 close quotation and having to place the quotation to the right of the automatically entered quotation with the arrow key.

Steps to reproduce

pres "

Enter some text

press"

You now have 2 ".
Example:
"some text""

Output from the debug section in the settings dialog

Relevant log output in the Log panel

@pbek

This comment has been minimized.

Owner

pbek commented Aug 3, 2018

I'm sorry, "Automatic closing" only works at the end of the line (otherwise there will be too many side-effects). So your 2nd " will not be closed. Was that what you were talking about?

@pbek pbek added the question label Aug 3, 2018

@joede

This comment has been minimized.

joede commented Aug 3, 2018

May be it would be a good idea to skip the insertion of the closing " if the the character next to the cursor is a "! This way the author can write without to be aware of the automatic closing.

By the way....

Marking a text and pressing " could surround the marked text with ". Would be nice...

@saurabh2804

This comment has been minimized.

saurabh2804 commented Aug 3, 2018

@pbek : While typing something, as soon as I enter ", the second " is entered right next to it to the right of the cursor. So if I continue typing, the text will be in quotes. However, when I have to end the quote, I have to press the right arrow key since the end quote has already been entered. Pressing the right arrow key beats the purpose of having the close quote entered automatically since we have to press a key for this anyways. IDE's (I have checked RStudio) have the same behaviour, however if I press quote close even if it has been entered by the IDE automatically, it just moves my cursor to the right of the quotes so that I may continue to type.
A workaround would be if I could disable the automatic addition of "

@pbek

This comment has been minimized.

Owner

pbek commented Aug 4, 2018

I'll take a look into it, thank you for your feedback.

@pbek

This comment has been minimized.

Owner

pbek commented Aug 5, 2018

Hm, what is if someone wants to add a "missing" " in front of an other "? Then his input would be ignored.

pbek added a commit that referenced this issue Aug 5, 2018

@pbek pbek added enhancement and removed question labels Aug 5, 2018

@pbek

This comment has been minimized.

Owner

pbek commented Aug 5, 2018

what is if someone wants to add a "missing" " in front of an other "? Then his input would be ignored.

I'll ignore that rare case...

It wasn't very easy to implement without causing any regressions, but it's done now:

18.08.1

  • if automatic bracket closing is enabled and if you are entering double quotes
    and the next character is already a double quote then the character will not
    be entered, but the cursor will be moved to the right

@pbek pbek added this to the 18.08.1 milestone Aug 5, 2018

@pbek

This comment has been minimized.

Owner

pbek commented Aug 5, 2018

There now is a new release, could you please test it and report if it works for you?

@saurabh2804

This comment has been minimized.

saurabh2804 commented Aug 5, 2018

It is working perfectly now. You did it in a day 🥇

@joede

This comment has been minimized.

joede commented Aug 5, 2018

It works. Thanks!

By the way... I have had a look at the changes in QMarkdownTextEdit::eventFilter. There I've seen, that you implement a different behaviour i.e. for '~' and '*' (handleBracketClosing). Why that? IMO you can simple allow nested sequences for all characters. Pressing ~ or ( for a second time now leads to an somehow unpleasant result.

@pbek

This comment has been minimized.

Owner

pbek commented Aug 5, 2018

I wrote quotationMarkCheck (https://github.com/pbek/qmarkdowntextedit/blob/0a43062dc5fe8ea2d261efa9c3d2f2ae9e425c70/qmarkdowntextedit.cpp#L434) today, maybe I will use it for other characters too in the future.

Pressing ~ or ( for a second time now leads to an somehow unpleasant result.

In what way?

@joede

This comment has been minimized.

joede commented Aug 5, 2018

It does not insert nested sequences.

  • pressing * 2 times leads to ****
  • pressing ~ 2 times leads to ~~~

If you enter some text after the "special character", the behaviour differ too. IMO both way leads to "unpleasant result" or illegal Markdown. I don't know if nested level of brackets are usefull.

  • after pressing * and entering some text, a 2nd level can be entered by * ==> *test***
  • after pressing ~ and entering some text, a 2nd level can be entered by ~ ==> ~test~~
  • after pressing ( and entering some text, a 2nd level can be entered by ( ==> (test()
@pbek

This comment has been minimized.

Owner

pbek commented Aug 5, 2018

pressing * 2 times leads to ****

and rightfully so to create the bold formatting
and markdown lists also have to be taken into account...

pressing ~ 2 times leads to ~~~

see above quotationMarkCheck ;)

you can never satisfy all "character magic" user-wishes without making other users with other use-cases angry and possibly create a lot of regressions in the process...

@joede

This comment has been minimized.

joede commented Aug 5, 2018

pressing * 2 times leads to ****

and rightfully so to create the bold formatting

No. The current way leads to incorrect Markdown. Press * than enter some text and press * again.

I must say, that I'm currently can't recognize all the side effects, but wouldn't it be a solution to handle a * like a closing " if the character left to the cursor is not a *?

In the case of brackets, nesting makes sense. So why not insert a closing bracket with every "opening" press?

@pbek

This comment has been minimized.

Owner

pbek commented Aug 6, 2018

No. The current way leads to incorrect Markdown. Press * than enter some text and press * again.

I don't think QOwnNotes will ever be able to detect every possible way that can be entered... those automation process should just be "helpers"

* is used for all kind of things, not just markdown formatting of bold and italic...

@pbek pbek closed this Aug 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment