Continue indentation in multiline dictionary, array or tuple #3

Merged
mattpauldavies merged 3 commits from main into main 2021-07-20 19:02:17 +02:00
mattpauldavies commented 2021-07-20 17:04:34 +02:00 (Migrated from github.com)

Following the update in this commit and this discussion; here is a suggested PR to continue indentation in dictionary, array or tuple blocks.

Currently when you hit return to create an array, dictionary or tuple block the cursor maintains the base indentation:

a = {
| # <- cursor here after return
}

b = [
| # <- cursor here after return
]

c = (
| # <- cursor here after return
)

This PR adds TupleExpression: continuedIndent(), DictionaryExpression: continuedIndent() and ArrayExpression: continuedIndent() to indentNodeProp which gives the following experience:

a = {
  | # <- cursor here after return
}

b = [
  | # <- cursor here after return
]

c = (
  | # <- cursor here after return
)
Following the update in [this commit](https://github.com/codemirror/lang-python/commit/11078ad3fc08fac5eda676e363226eef2d65d0bb) and [this discussion](https://github.com/codemirror/codemirror.next/issues/538); here is a suggested PR to continue indentation in dictionary, array or tuple blocks. Currently when you hit return to create an array, dictionary or tuple block the cursor maintains the base indentation: ```python a = { | # <- cursor here after return } b = [ | # <- cursor here after return ] c = ( | # <- cursor here after return ) ``` This PR adds `TupleExpression: continuedIndent()`, `DictionaryExpression: continuedIndent()` and `ArrayExpression: continuedIndent()` to `indentNodeProp` which gives the following experience: ```python a = { | # <- cursor here after return } b = [ | # <- cursor here after return ] c = ( | # <- cursor here after return ) ```
marijnh commented 2021-07-20 17:12:11 +02:00 (Migrated from github.com)

Good idea! Not sure why those aren't there yet. I think delimitedIndent is a better match for these though, since it allows the end bracket to be deindented (as in your examples), and supports 'aligned' indentation when elements start on the line of the opening bracket.

Good idea! Not sure why those aren't there yet. I think [`delimitedIndent`](https://codemirror.net/6/docs/ref/#language.delimitedIndent) is a better match for these though, since it allows the end bracket to be deindented (as in your examples), and supports 'aligned' indentation when elements start on the line of the opening bracket.
mattpauldavies commented 2021-07-20 18:22:23 +02:00 (Migrated from github.com)

Ahh thanks, @marijnh, I wasn't 100% sure which was the best method to use. Updated accordingly 👍

Ahh thanks, @marijnh, I wasn't 100% sure which was the best method to use. Updated accordingly 👍
marijnh commented 2021-07-20 19:02:24 +02:00 (Migrated from github.com)

Thanks!

Thanks!
microbit-matt-hillsdon (Migrated from github.com) reviewed 2021-07-24 13:50:39 +02:00
microbit-matt-hillsdon (Migrated from github.com) commented 2021-07-24 13:50:39 +02:00
These aren't compiling for me. I think they're missing a value for `closing`. https://github.com/codemirror/language/blob/main/src/indent.ts#L264 Compare with: https://github.com/codemirror/lang-javascript/blob/main/src/javascript.ts#L23
microbit-matt-hillsdon (Migrated from github.com) reviewed 2021-07-24 13:51:40 +02:00
microbit-matt-hillsdon (Migrated from github.com) commented 2021-07-24 13:51:40 +02:00

Interestingly the ./bin/cm.js build completes just fine but the demo doesn't work if I switch it to use lang-python.

Interestingly the `./bin/cm.js build` completes just fine but the demo doesn't work if I switch it to use lang-python.
marijnh (Migrated from github.com) reviewed 2021-07-24 14:23:34 +02:00
marijnh (Migrated from github.com) commented 2021-07-24 14:23:34 +02:00

Indeed, that patch never typechecked. 18462e7347 should fix it.

Indeed, that patch never typechecked. 18462e73470c78b should fix it.
mattpauldavies (Migrated from github.com) reviewed 2021-07-26 13:19:06 +02:00
mattpauldavies (Migrated from github.com) commented 2021-07-26 13:19:05 +02:00

Apologies for missing that gents. And thanks @marijnh for fixing! 🙌

Apologies for missing that gents. And thanks @marijnh for fixing! 🙌
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/lang-python!3
No description provided.