cursorless-dev / cursorless

Don't let the cursor slow you down

Home Page:https://www.cursorless.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

saidelike opened this issue · comments

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}
  • we set the selection in cursorless from (0,11) to (0,11) which translates to neovim to (1,11),(1,11)
  • then, when we get the selection in neovim from (1,11),(1,12) which translates to cursorless to (0,10),(0,11), which is different from what we had set
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
      }
    }
  ]
}