CodinGame / monaco-vscode-api

VSCode public API plugged on the monaco editor
MIT License
205 stars 29 forks source link

`window.activeTextEditor` has the wrong type #456

Closed joneugster closed 1 week ago

joneugster commented 1 week ago

I'm sorry if this is a dumb question and I don't fully understand what I'm doing.

But, with import { window } from 'vscode' if I look at window.activeTextEditor.selection it has the following type

Object { _start: {…}, _end: {…}, _anchor: {…}, _active: {…} }
  _active: Object { _line: 0, _character: 0 }
  _anchor: Object { _line: 0, _character: 0 }
  _end: Object { _line: 0, _character: 0 }
  _start: Object { _line: 0, _character: 0 }
<prototype>: Object { … }

whereas in VSCode, it seems all of these do not have the leading underscore, compare to the defined TextEditor interface in @types/vscode. Why is this difference?

CGNonofr commented 1 week ago

You're comparing the implementation details with the interface. There is no supposed difference as the exact same code is used in both places.

Are you encountering any issue?

joneugster commented 1 week ago

Hmm, I am experiencing issues, but I think that was a complete misjudgment, and had nothing to do with the _character.

I don't think I can minimalise this easily, but I know have a code-snippet that looks like this:

range: {
    // start: selection.start, // This fails...
    // end: selection.end,
    start: {line: selection.start.line, character: selection.start.character}, // this succeeds... `selection.start._character` also suceeded
    end: {line: selection.end.line, character: selection.end.character}
},

I don't understand why the latter works, but I don't think it has anything to do with this package.

Sorry for the noise and thanks for the fast answer!