Skip to content

Commit 80941dc

Browse files
committed
Slight refactor
1 parent af39eb8 commit 80941dc

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

src/actions/base.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { isLiteralMode, unmapLiteral } from '../configuration/langmap';
1111
export abstract class BaseAction implements IBaseAction {
1212
abstract readonly actionType: ActionType;
1313

14-
public name = '';
14+
public readonly name: string | undefined;
1515

1616
/**
1717
* If true, the cursor position will be added to the jump list on completion.
@@ -204,14 +204,12 @@ export abstract class BaseCommand extends BaseAction {
204204

205205
const resultingCursors: Cursor[] = [];
206206

207-
const cursorsToIterateOver = vimState.cursors
208-
.map((x) => new Cursor(x.start, x.stop))
209-
.sort((a, b) =>
210-
a.start.line > b.start.line ||
211-
(a.start.line === b.start.line && a.start.character > b.start.character)
212-
? 1
213-
: -1,
214-
);
207+
const cursorsToIterateOver = [...vimState.cursors].sort((a, b) =>
208+
a.start.line > b.start.line ||
209+
(a.start.line === b.start.line && a.start.character > b.start.character)
210+
? 1
211+
: -1,
212+
);
215213

216214
let cursorIndex = 0;
217215
for (const { start, stop } of cursorsToIterateOver) {

src/actions/commands/join.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,12 @@ class ActionJoin extends BaseCommand {
114114
}
115115

116116
public override async execCount(position: Position, vimState: VimState): Promise<void> {
117-
const cursorsToIterateOver = vimState.cursors
118-
.map((x) => new Cursor(x.start, x.stop))
119-
.sort((a, b) =>
120-
a.start.line > b.start.line ||
121-
(a.start.line === b.start.line && a.start.character > b.start.character)
122-
? 1
123-
: -1,
124-
);
117+
const cursorsToIterateOver = [...vimState.cursors].sort((a, b) =>
118+
a.start.line > b.start.line ||
119+
(a.start.line === b.start.line && a.start.character > b.start.character)
120+
? 1
121+
: -1,
122+
);
125123

126124
const resultingCursors: Cursor[] = [];
127125
for (const [idx, { start, stop }] of cursorsToIterateOver.entries()) {

src/actions/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { VimState } from '../state/vimState';
44
export type ActionType = 'command' | 'motion' | 'operator' | 'number';
55

66
export interface IBaseAction {
7-
name: string;
7+
readonly name: string | undefined;
88
readonly actionType: ActionType;
99
readonly isJump: boolean;
1010
readonly createsUndoPoint: boolean;

0 commit comments

Comments
 (0)