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

Bracket pairing #386

Closed
qazip opened this Issue Nov 14, 2016 · 46 comments

Comments

Projects
None yet
5 participants
@qazip

qazip commented Nov 14, 2016

Hello,

I've recently started using QOwnNotes (though not with OwnCloud), and there's something that I'm missing:

  • Bracket matching

If I type "(", I expect it to automatically close the bracket and place the cursor in the middle, like so "(|)". The same is true for different brackets, quotation marks and start thingies "*".

Is this something that you'd be interested in adding to QOwnNotes?

@pbek pbek added the enhancement label Nov 14, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Nov 14, 2016

Thank you for your suggestion, I will look into it.

@pbek

This comment has been minimized.

Owner

pbek commented Nov 14, 2016

16.11.10

  • implemented automatic entering of matching characters like closing parenthesis
    • characters like ", ', *, (, [ or { are automatically closed
    • ", ' and * are only closed if there isn't already an opening
      character in the current text block

@pbek pbek added this to the 16.11.10 milestone Nov 14, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Nov 14, 2016

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

@qazip

This comment has been minimized.

qazip commented Nov 14, 2016

Is the new release already available in the PPA?

@qazip

This comment has been minimized.

qazip commented Nov 14, 2016

I already saw it is. Thank you for adding this!

I suggest doing the same for deletion, that is, when deleting one bracket, automatically delete the other, if nothing is typed inside the bracket. For example, type "(", it'll automatically pair with "(|)". Now if I delete "(", it should automatically delete its pair, ")".

One off-topic question: Where does qownnotes store its config file, under Ubuntu?

@pbek

This comment has been minimized.

Owner

pbek commented Nov 14, 2016

I will see about the deleting of brackets...

You'll find the configuration in ~/.config/PBE/QOwnNotes.conf

@cornimueller

This comment has been minimized.

cornimueller commented Nov 14, 2016

I see that this is a useful feature for some, but others (like me) don't want their editor to add characters they didn't type.
Is it possible to make this behaviour optional?
(And maybe also the older feature which automatically begins the line with an enumeration symbol if the line above had one.)

@pbek

This comment has been minimized.

Owner

pbek commented Nov 14, 2016

No one has complained yet... ;)

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

Now there was a complain. 😸

@shaununderwood

This comment has been minimized.

shaununderwood commented Nov 16, 2016

Yep, how to turn this feature off?

QOwnNotes clean unassuming interface - for me - is it's charm. Have you any idea how hard it is to find a decent, no frills text editor? VERY hard. Your project is perfect in so many ways! Clean UI. Syncs seamlessly to owncloud. built in md with preview. Nice files list with overview and folder-view. Loads in seconds. Crashes sometimes when it saves (on mac), but restarts in a flash without any data loss.

Also, you are auto-inserting stuff, but if I delete the initial ' or * the auto-inserted char stays there! That's double annoying.

If you haven't guessed already, I really love your project.

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

Thank you for your kind words, @shaununderwood

Yep, how to turn this feature off?

I'm working on that, I guess I will turn it off by default.

Crashes sometimes when it saves (on mac), but restarts in a flash without any data loss.

Can you please open an issue with a crash report. In the settings you'll find Debug options, can you please turn file logging on and also post the lines before the crash.

@qazip

This comment has been minimized.

qazip commented Nov 16, 2016

I see that this is a useful feature for some, but others (like me) don't want their editor to add characters they didn't type.

I agree that this feature should be opt-out (or even opt-in), but I almost never use unpaired-brackets. In fact, I don't remember ever using it. If I did, it was a mistake. I reckon most people would welcome this feature. But of course, there are always exceptions to the rule..

Also, you are auto-inserting stuff, but if I delete the initial ' or * the auto-inserted char stays there! That's double annoying.

As far as I'm aware, @pbek is considering adding the delete-in-pairs function.

@shaununderwood

This comment has been minimized.

shaununderwood commented Nov 16, 2016

@mimf
... but I almost never use unpaired-brackets. In fact, I don't remember ever using it. If I did, it was a mistake. I reckon most people would welcome this feature. But of course, there are always exceptions to the rule..

The bracketing I can see the logic behind your bracketing suggestion - I'll keep that in mind going forward - however, * are used for lists, ' are used for abbreviations ( eg aren't they? :)

I agree that this feature should be opt-out (or even opt-in)

as an existing user opt-in would be my expectation, but as long as we've an option (perhaps for each pairing?) that'd be great.

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

however, * are used for lists,

QOwnNotes favors -, * is also used for italic and bold, so "closing" them might make sense
hard decision... maybe no auto-closing at the start of a line?

' are used for abbreviations

never saw that, which markdown syntax is that?

as an existing user opt-in would be my expectation

I guess 99% of the people wouldn't search for a setting to turn it on, default is king.
I currently tend to make it opt-out...

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

As far as I'm aware is considering adding the delete-in-pairs function.

I'll try to, but it's more hard and dangerous to determine how and when to delete what character... (plus there a several ways for a user to delete characters)

@shaununderwood

This comment has been minimized.

shaununderwood commented Nov 16, 2016

however, * are used for lists,

QOwnNotes favors -

Okay, I'll keep that in mind. I guess you can interpret your md as you wish. http://bit.ly/2fVpWu6 has single *s as bullet lists.

' are used for abbreviations

never saw that, which markdown syntax is that?

None, it's English grammar: can't, wouldn't, that'll, it's, one's, they'll, 10's of thousands. 'owdy part'er. 'ou'll know me by now.

That's just for abbreviations and possession. Apostrophes, they're a pretty important grammatical tool. :)

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

Okay, I'll keep that in mind. I guess you can interpret your md as you wish. http://bit.ly/2fVpWu6 has single *s as bullet lists.

Yes, of course they are used. I'll think of something.

None, it's English grammar

How could I forget about that. :D
I will remove ', thank you.

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

QOwnNotes favors -

Actually that's not even true, I also handled * as list character.

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

16.11.11

  • more changes to closing of brackets and markdown formatting characters
    • you can now disable the feature in the Editor settings
    • added closing of < and removed closing of '
    • * will now only be closed if not used in lists
      • it will be checked if it is on the beginning of a block or if
        it has just whitespaces in front of it

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

@shaununderwood

This comment has been minimized.

shaununderwood commented Nov 16, 2016

The apostrophe is working as expected.
The * also works as before :)
Great Thanks!

@pbek

This comment has been minimized.

Owner

pbek commented Nov 16, 2016

Great, thank you for testing!

@pbek

This comment has been minimized.

Owner

pbek commented Nov 17, 2016

I think I will disable the automatic closing of characters if not entered at the end of a text block... It's pretty annoying if you want to enter a bracket in front of an existing text and you get the closing too. And it will even be kind of destructive when I add the automatic bracket removal feature.

Any thoughts on that?

@qazip

This comment has been minimized.

qazip commented Nov 17, 2016

I agree with that. I suggest taking a look at SublimeText.com or atom.io (or even the bracket pairing extension for Vim). They all follow the same standards.

@shaununderwood

This comment has been minimized.

shaununderwood commented Nov 17, 2016

@pbek

This comment has been minimized.

Owner

pbek commented Nov 17, 2016

16.11.12

  • the closing of brackets and markdown formatting characters is now only
    allowed if the cursor was at the end of a block
  • closing brackets and markdown formatting characters are now
    automatically removed if the opening character is removed with
    Backspace
    • opening characters can be (, [, {, <, * or "
    • you can disable this feature in the Editor settings
    • if text was selected closing characters will not be removed

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

@qazip

This comment has been minimized.

qazip commented Nov 17, 2016

@pbek, from the testing I did, it works fantastically.

That's some fast release. This feature was requested just 3 days ago, and it's already here. Thank you for the hard work.

@pbek

This comment has been minimized.

Owner

pbek commented Nov 17, 2016

Thank you. And it was not the only thing I worked on. ;)

@pbek pbek closed this Nov 17, 2016

@qazip

This comment has been minimized.

qazip commented Nov 26, 2016

The pairing of * is not working here. I'm not on a list, yet it's not pairing. Is this expected behaviour?

@pbek

This comment has been minimized.

Owner

pbek commented Nov 26, 2016

@mimf, can you please be more specific on what you did, what happened and what you expected.

@qazip

This comment has been minimized.

qazip commented Nov 26, 2016

Of course, my bad:

Just type * and that's all I got. I expected *|*. However, If I type 3 times *, It will eventually autopair 1 of them, and I'll end up with ***|*. I expected **|**.

@qazip

This comment has been minimized.

qazip commented Nov 26, 2016

Well, I just found out that behavior I mentioned only happens at the start of a line.. I suppose this is expected. My bad, sorry!

@pbek

This comment has been minimized.

Owner

pbek commented Nov 26, 2016

Well, I just found out that behavior I mentioned only happens at the start of a line.. I suppose this is expected.

exactly ;)

@qazip

This comment has been minimized.

qazip commented Dec 1, 2016

Well, if one is not at the start of a line and one types **, shouldn't it pair to **|**?

@pbek

This comment has been minimized.

Owner

pbek commented Dec 1, 2016

We don't do pairing if we are not at the end of the line, too dangerous.

@qazip

This comment has been minimized.

qazip commented Dec 1, 2016

But it pairs the first *, just not the second..

@pbek

This comment has been minimized.

Owner

pbek commented Dec 1, 2016

Can you please explain in more detail and step by step what you did, what happened and what you expected.

@qazip

This comment has been minimized.

qazip commented Dec 2, 2016

My bad again.

Type something and then hit *. You'll see that it pairs and becomes *|*. Now, since it paired, you expect the same to happen if you type * again, but that doesn't happen. What you get is **|* and what I'd expect is **|**. "|" represents the cursor.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 2, 2016

Like I said we do auto-adding and removing only at the end of a line. Everything else can prove to be dangerous.

@qazip

This comment has been minimized.

qazip commented Dec 3, 2016

Well, yes, but we're at the end of a line.. Other than the *, that is. I don't think the behaviour is consistent. It pairs the first *, but not the second. It's hard to make something bold that way. But well, it seems you're aware of it.

@pbek

This comment has been minimized.

Owner

pbek commented Dec 3, 2016

No character is paired when it's not entered at the end of the line. The 2nd time you enter a * it's not at the end of the line.
You can also create all * characters by typing Ctrl + B.

But I now did this, we'll see if this is misbehaving:

16.12.0

  • made a special allowance for allowing entering two * characters in a row and closing both of them when the first * was at the end of the line
@pbek

This comment has been minimized.

Owner

pbek commented Dec 3, 2016

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

@qazip

This comment has been minimized.

qazip commented Dec 3, 2016

Damn, this is some nice priority support! Yes, the * works fine.

However now one could argue that the same should apply to all the characters, such as ( {[ " '....

Why is it dangerous adding such characters at the end of a line?

@pbek

This comment has been minimized.

Owner

pbek commented Dec 3, 2016

if you scroll a bit up...

I think I will disable the automatic closing of characters if not entered at the end of a text block... It's pretty annoying if you want to enter a bracket in front of an existing text and you get the closing too. And it will even be kind of destructive when I add the automatic bracket removal feature.

😸

@qazip

This comment has been minimized.

qazip commented Dec 3, 2016

Yes, you're right. But you should take into account when the following character is also a bracket (or similar). Just like sublime/atom and the likes do (and you/qownnotes also, with the * character).

Also, an additional feature. If we've "blabla" and select that text, wouldn't it be cool if by entering "(" it would make it "(blabla)" instead of deleting blabla and exchanging it with "()"? 😄

@pbek

This comment has been minimized.

Owner

pbek commented Dec 3, 2016

additional feature

that could be nice for some or drive others crazy, who expect the text to be removed :)

@richarson

This comment has been minimized.

richarson commented Dec 4, 2016

Also, an additional feature. If we've "blabla" and select that text, wouldn't it be cool if by entering "(" it would make it "(blabla)" instead of deleting blabla and exchanging it with "()"?

I agree with @pbek here, I think the best for this would be shortcuts, e.g.: press Ctrl+Shift+( to enclose the selected text in parentheses, and so on for other special characters.

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