Skip to content

Intelligent unmatched pairs based on indentation #49

@Saghen

Description

@Saghen

Feature Description

Currently, when we calculate unmatched pairs where there's multiple possible solutions, we pick the closest pair:

[ { ( (  ) } ]
0 1 * 3  3 1 0

Note: The number indicates the depth (stack height) of the match and decides the color. Unmatched opening pairs still increase the depth.

This doesn't always lead to the best result, for example in:

fn foo() {
      00 *
  if bar {
         1
    println!("hello world")

}
1

The first { will be marked as unmatched instead of the { in if bar {. Instead, given that we have the following:

fn foo() {
      00 0
}
0

And the user types if bar {, the minimum possible edit would be setting { in if bar { as unmatched. If we instead matched it on the final }, we would need to update } with a larger stack height (new color).

Minimal edit:

fn foo() {
      00 0
  if bar {
         *
}
0

Alternative edit:

fn foo() {
      00 *
  if bar {
         1
}
1

I'm not sure if this idea actually makes sense, but it could be a fun experiment atleast

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions