-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add indented interpolated values feature #11
Comments
Should this behaviour (applying the contextual indentation to all line-wraps) be the default behaviour? And if the user wants line-wraps to have 0-indentation, then use special syntax for that? 🤔 This seems like it's what users will want to happen most often, and |
That's a very good question. (1) I agree that this better be default behaviour rather than not. And yeah, use some special syntax for 0-indentation for line-wraps, perhaps some putTextLn [int||
The text:
#<{multilineText}
|]
(2) Next question, when will this trigger? So I propose, the indentation of multiline text to trigger only if the placeholder is the first non-whitespace thing at the line - in this case the entire interpolated text will use the respective indentation. Otherwise, nothing special should happen? putTextLn [int||
My text:
#{multilineText}
And also a text: #{multlineText}, period.
|]
I'm not sure that there is a reasonable strategy for the second part of the text here, so probably better just do nothing. (3) And maybe sometimes it actually makes sense to ignore the triggering rule mentioned above and repeat the text before the placeholder. For instance: putTextLn [int||
Expected:
| #|{expected}
Got:
| #|{got}
|]
(4) Any switches to add? Since we allow fine-tuning via the syntax of the placeholder ( But this should be tunable in the interpolator itself indeed. Some people may not like this default behaviour with auto-indentation. |
Ooh great point! Ok it seems there's actually multiple possible "indentation / vertical alignment" modes we could implement. Given this code (the exact placeholder syntax doesn't matter here):
We could support the following modes:
Hmm I'm not sure, I agree it may be useful in some situations, but this seems like a more complex case (seems almost like a "template for a line"). My humble opinion is that this should be outside the scope of nyan-interpolation. Choosing the default mode: In my first comment I suggested "Indent at current column" should be the default. But, as you pointed out, it may not always be desirable. In that case, maybe "Inherit indentation" would be a good default? It would look good in the scenario you described at the very top and in the scenario you described in your point (2).
Yeah I don't think we need switches. Each placeholder should choose how to display itself. I have no idea what syntax we could for the placeholders to support 3 modes though 😅 Am I making things too complex? |
Cool, these all make sense for me 👍
Okay, yeah, I agree here, that's a too far-going proposal.
I think that's a very good suggestion. My proposal from the previous post to have conditional default (indent only if having preceding whitespaces) - on a second thought, it is tricky and unintuitive. And "inherit indentation" - it is unconditional, but very sensible, takes a perfect balance between "too smart to be default" and "too rarely useful". Let's really go with it.
Ah no, I personally think this is just fine, and all 3 seem to be worth having 😋 If users find that too complex, they can just not use all 3 😄 Aand, I will likely add a way to define custom "syntax -> indentation behaviour" mappings eventually. |
Thanks for this discussion, now everything seems mostly clear, I hope to start implementing this soon 😸 |
Clarification and motivation
What would be a replacement for this?:
Probably we need some special construct for this, this can look like
where
#|
stands for preserving the current indentation for the multiline text.Acceptance criteria
The text was updated successfully, but these errors were encountered: