eraserhd / parinfer-rust

A Rust port of parinfer.
ISC License
546 stars 42 forks source link

Wonky cursor positions? #90

Open eneroth opened 4 years ago

eneroth commented 4 years ago

I'd love some help with this. I'm probably calculating my offsets wrong or something, but I'm not quite sure what I'm doing wrong.

Args:

{
  "mode": "smart",
  "text": "[1 \n2]",
  "options": {
    "prevText": "[1 2]",
    "prevCursorLine": 0,
    "prevCursorX": 3,
    "cursorLine": 1,
    "cursorX": 0
  }
}

Output:

{
  "text": "[1] \n2",
  "success": true,
  "error": null,
  "cursorX": 0,
  "cursorLine": 1,
  "tabStops": [
    {
      "ch": "[",
      "x": 0,
      "lineNo": 0,
      "argX": 3
    }
  ],
  "parenTrails": [
    {
      "lineNo": 0,
      "startX": 2,
      "endX": 3
    }
  ],
  "parens": []
}

(I'm using WASM)

eraserhd commented 4 years ago

Hi!

It's been a while since I've had this loaded into my brain, but as far as I can tell, you are right that the behavior is wrong.