* Updates VSCodeVim's internal representation of cursors to match VSCode's selections. * This loses some information, so it should only be done when necessary.
()
| 125 | * This loses some information, so it should only be done when necessary. |
| 126 | */ |
| 127 | public syncCursors() { |
| 128 | // TODO: getCursorsAfterSync() is basically this, but stupider |
| 129 | const { selections } = this.vimState.editor; |
| 130 | // TODO: this if block is a workaround for a problem described here https://github.com/VSCodeVim/Vim/pull/8426 |
| 131 | if ( |
| 132 | selections.length === 1 && |
| 133 | selections[0].isEqual(new Range(new Position(0, 0), new Position(0, 0))) |
| 134 | ) { |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | if ( |
| 139 | !this.vimState.cursorStartPosition.isEqual(selections[0].anchor) || |
| 140 | !this.vimState.cursorStopPosition.isEqual(selections[0].active) |
| 141 | ) { |
| 142 | this.vimState.desiredColumn = selections[0].active.character; |
| 143 | } |
| 144 | |
| 145 | this.vimState.cursors = selections.map(({ active, anchor }) => |
| 146 | active.isBefore(anchor) ? new Cursor(anchor.getLeft(), active) : new Cursor(anchor, active), |
| 147 | ); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * This is easily the worst function in VSCodeVim. |
no test coverage detected