diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/commands.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 59ef98ecf..1a0805bd3 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -156,12 +156,25 @@ export function moveItem(ctx: Ctx, direction: ra.Direction): Cmd { | |||
156 | 156 | ||
157 | if (!edit) return; | 157 | if (!edit) return; |
158 | 158 | ||
159 | let cursor: vscode.Position | null = null; | ||
160 | |||
159 | await editor.edit((builder) => { | 161 | await editor.edit((builder) => { |
160 | client.protocol2CodeConverter.asTextEdits(edit.edits).forEach((edit: any) => { | 162 | client.protocol2CodeConverter.asTextEdits(edit.edits).forEach((edit: any) => { |
161 | builder.replace(edit.range, edit.newText); | 163 | builder.replace(edit.range, edit.newText); |
164 | |||
165 | if (direction === ra.Direction.Up) { | ||
166 | if (!cursor || edit.range.end.isBeforeOrEqual(cursor)) { | ||
167 | cursor = edit.range.end; | ||
168 | } | ||
169 | } else { | ||
170 | if (!cursor || edit.range.end.isAfterOrEqual(cursor)) { | ||
171 | cursor = edit.range.end; | ||
172 | } | ||
173 | } | ||
162 | }); | 174 | }); |
163 | }).then(() => { | 175 | }).then(() => { |
164 | editor.selection = new vscode.Selection(editor.selection.end, editor.selection.end); | 176 | const newPosition = cursor ?? editor.selection.start; |
177 | editor.selection = new vscode.Selection(newPosition, newPosition); | ||
165 | }); | 178 | }); |
166 | }; | 179 | }; |
167 | } | 180 | } |