cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.09k stars 77 forks source link

neovim: better selection range when selection is empty and at end of line #2376

Open saidelike opened 1 month ago

saidelike commented 1 month ago

this may be related to #2322

recorded/marks/chuckNothing fails atm because of the way we set/get selection. When the selection is empty and at the end of the line, we currently don't get the same selection we would have previously set.

languageId: plaintext
command:
  version: 1
  spokenForm: chuck nothing
  action: remove
  targets:
    - type: primitive
      mark: {type: nothing}
initialState:
  documentContents: hello world
  selections:
    - anchor: {line: 0, character: 11}
      active: {line: 0, character: 11}
  marks: {}
finalState:
  documentContents: hello world
  selections:
    - anchor: {line: 0, character: 11}
      active: {line: 0, character: 11}
2024-04-05 20:27:12 WAR runTest(recorded/marks/chuckNothing)...
2024-04-05 20:27:12 WAR updateTextEditor(): window:1000, buffer:1, lines=["hello world"]
2024-04-05 20:27:12 WAR bufferGetSelections(): selections=(0, 0), (0, 0) neovim=(1,1),(1,1),reverse=true
2024-04-05 20:27:12 WAR windowGetVisibleRanges(): range=(0, 0), (0, 10)
2024-04-05 20:27:12 WAR toNeovimEditor(): updating document: buffer=1
2024-04-05 20:27:12 WAR toNeovimEditor(): updating editor: window=1000
2024-04-05 20:27:12 WAR bufferSetSelections() selections=(0,11),(0,11) luaCode="return require("talon.cursorless").select_range(1, 11, 1, 11)"
2024-04-05 20:27:12 WAR updateTextEditor(): window:1000, buffer:1, lines=["hello world"]
2024-04-05 20:27:12 WAR bufferGetSelections(): selections=(0, 10), (0, 11) neovim=(1,11),(1,12),reverse=false
2024-04-05 20:27:12 WAR windowGetVisibleRanges(): range=(0, 0), (0, 10)
 2024-04-05 20:27:12 WAR toNeovimEditor(): updating document: buffer=1
2024-04-05 20:27:12 WAR toNeovimEditor(): updating editor: window=1000
2024-04-05 20:27:18 WAR Failed test: recorded/marks/chuckNothing
2024-04-05 20:27:18 WAR Thrown error: Unexpected final state: expected { …(2) } to deeply equal { …(2) }
2024-04-05 20:27:18 WAR Expected: {
  "documentContents": "hello world",
  "selections": [
    {
      "anchor": {
        "line": 0,
        "character": 11
      },
      "active": {
        "line": 0,
        "character": 11
      }
    }
  ]
}
2024-04-05 20:27:18 WAR Actual: {
  "documentContents": "hello world",
  "selections": [
    {
      "anchor": {
        "line": 0,
        "character": 10
      },
      "active": {
        "line": 0,
        "character": 11
      }
    }
  ]
}