elan-language / LanguageAndIDE

Apache License 2.0
3 stars 0 forks source link

Could we detect and swallow a close-bracket at the end of a bracketed field? #685

Open stirlingstout opened 2 months ago

stirlingstout commented 2 months ago

image If I now type ) I'd expect it to be taken as the closing ) but that doesn't seem to work.

Compare with image where the typing of ] gets swallowed

richardpawson commented 2 months ago

The two examples given are quite different in nature.

In the first case the (black) ) is not part of the field, it is part of the frame's boilerplate.

In the second case there is no 'swallowing' of the ] - the (white) prompt indicates that you must still enter it, either by typing the character, or by using cursor/tab/enter, in which case the prompted (Roman) character(s) will be added for you.

By contrast where you do see 'swallowing' is that if you had typed queue.removeAt( the ( would be swallowed, so it is reasonable to ask why it can't do the same in your first case.

The answer is that it could but there is a great deal more involved. To swallow the closing ) we would need to implement the following rules:

'In (specifically) in a field that is enclosed by brackets defined in the frame IF

1) the text cursor is at the right hand end of the field AND 2) the user types ) AND 3) this is not closing an existing open bracket within the field THEN

Part 3 is particularly tricky because there could be other brackets used within param values expressions, or within quotes. But it could be done.

(I have changed the title of the ticket, because it is not a general issue to do with swallowing, it is a very specific case.)

stirlingstout commented 2 months ago

We have a situation where, in a string, this seems to work, e.g., ), }, and " get swallowed in the example below. I think a problem is that to the naive user (and initially everyone will be a naive user) the two situations look the same.

[image: image.png] All the best.

John

Sent from (one of): one of my Raspberry Pi computers the Android phone or tablet the Windows desktop one of the Windows laptops/notebooks/tablets one of the Macbook Airs the iPad Pro or even the LG TV!

On Tue, 6 Aug 2024 at 10:17, Richard Pawson @.***> wrote:

The two examples are quite different in nature.

The second case it not swallowing the ] - it is entering it. (The white ] is a prompt - indicating that you need to type it, or cursor/tab/enter to have it put in automatically as part of the field.

The first case is quite different, the (black) ) is not part of the field, it is part of the frame boilerplate.

I am changing the title because I don't think this is a generalised point, it is a specific issue to do with the context. What you are asking for would require a special rule that says:

'In a field, if:

  1. tne cursor is at the right hand end AND
  2. the user types ) AND
  3. this is not closing an existing open bracket within the field AND
  4. there is a ) in the frame immediately after the field THEN

    • swallow the ) (i.e. don't include it in the field)
    • behave as though the user had pressed Enter instead

As you can see this will be quite a difficult to implement (even 3 on its own is going to be quite difficult). But it could be done.

— Reply to this email directly, view it on GitHub https://github.com/elan-language/LanguageAndIDE/issues/685#issuecomment-2270796668, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQQABZMY4HNLASFWLUGTXTZQCID3AVCNFSM6AAAAABMB3ESNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZQG44TMNRWHA . You are receiving this because you authored the thread.Message ID: @.***>