Skip to content

Commit

Permalink
Merge branch 'master' of github.com:VSCodeVim/Vim into feature/implem…
Browse files Browse the repository at this point in the history
…ent_normal_command
  • Loading branch information
s-kai273 committed May 20, 2024
2 parents a3926ed + a3bd036 commit dbd0bd2
Show file tree
Hide file tree
Showing 16 changed files with 5,818 additions and 5,701 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Change Log

## [v1.27.3](https://github.com/vscodevim/vim/tree/v1.27.3) (2024-05-20)

### Added

- Custom digraphs can be added via `:dig[raphs]` ([@J-Fields](https://github.com/J-Fields)).
- `:Ex[plore]` is mapped to `workbench.view.explorer` ([@JaiminBrahmbhatt](https://github.com/JaiminBrahmbhatt)).

### Changed

- When used with a count, `<C-d>` and `<C-u>` set the `scroll` option to the count ([@ontanj](https://github.com/ontanj)).

### Fixed

- Fix `:s[ubstitute]` with the `n` flag moving cursor ([@J-Fields](https://github.com/J-Fields)).
- Fix special marks displaying in gutter ([@shinohara-rin](https://github.com/shinohara-rin)).
- Fix several edge cases of `<C-o>` ([@harunou](https://github.com/harunou)).
- Fix incorrect digraph mappings ([@mlbykn](https://github.com/mlbykn)).
- Fix `gv` after visual selection with mouse or command ([@zyd2001](https://github.com/zyd2001)).
- Fix `gv` being unaffected by `m<` and `m>` ([@J-Fields](https://github.com/J-Fields)).

## [v1.27.2](https://github.com/vscodevim/vim/tree/v1.27.2) (2023-12-22)

### Added
Expand Down
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ Now follows an exhaustive list of every known Vim command that we could find.
| :white_check_mark: | `. | go to the position of the last change in this file |
| :white_check_mark: | '. | go to the position of the last change in this file |
| :arrow_down: | '{a-zA-Z0-9[]'"<>.} | same as `, but on the first non-blank in the line |
| :arrow_down: | :marks | print the active marks |
| :white_check_mark: | :marks | print the active marks |
| :white_check_mark: | :1234: CTRL-O | go to Nth older position in jump list |
| :white_check_mark: | :1234: CTRL-I | go to Nth newer position in jump list |
| :arrow_down: | :ju[mps] | print the jump list |
| :white_check_mark: | :ju[mps] | print the jump list |

## Various motions

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Vim",
"description": "Vim emulation for Visual Studio Code",
"icon": "images/icon.png",
"version": "1.27.2",
"version": "1.27.3",
"publisher": "vscodevim",
"galleryBanner": {
"color": "#e3f4ff",
Expand Down Expand Up @@ -1200,7 +1200,7 @@
"@types/diff": "5.2.1",
"@types/diff-match-patch": "1.0.36",
"@types/glob": "8.1.0",
"@types/lodash": "4.17.1",
"@types/lodash": "4.17.4",
"@types/mocha": "10.0.6",
"@types/node": "18.19.33",
"@types/parsimmon": "1.10.9",
Expand Down Expand Up @@ -1228,7 +1228,7 @@
"mocha": "10.4.0",
"plugin-error": "2.0.1",
"prettier": "3.2.5",
"sinon": "17.0.2",
"sinon": "18.0.0",
"ts-loader": "9.5.1",
"typescript": "5.4.5",
"vsce": "2.15.0",
Expand Down
17 changes: 10 additions & 7 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { PositionDiff, earlierOf, laterOf, sorted } from './../../common/motion/
import { NumericString } from './../../common/number/numericString';
import { configuration } from './../../configuration/configuration';
import {
DotCommandStatus,
Mode,
isVisualMode,
visualBlockGetBottomRightPosition,
Expand Down Expand Up @@ -705,17 +706,17 @@ SearchCommandLine.onSearch = async (vimState: VimState, direction: SearchDirecti
class CommandDot extends BaseCommand {
modes = [Mode.Normal];
keys = ['.'];
override createsUndoPoint = true;

public override async execCount(position: Position, vimState: VimState): Promise<void> {
if (globalState.previousFullAction) {
const count = vimState.recordedState.count || 1;

for (let i = 0; i < count; i++) {
vimState.recordedState.transformer.addTransformation({
type: 'replayRecordedState',
recordedState: globalState.previousFullAction,
});
}
vimState.recordedState.transformer.addTransformation({
type: 'replayRecordedState',
count,
recordedState: globalState.previousFullAction,
});
}
}
}
Expand Down Expand Up @@ -1664,7 +1665,7 @@ class ActionJoinNoWhitespaceVisualMode extends BaseCommand {
}

@RegisterAction
class ActionReplaceCharacter extends BaseCommand {
export class ActionReplaceCharacter extends BaseCommand {
modes = [Mode.Normal];
keys = ['r', '<character>'];
override createsUndoPoint = true;
Expand Down Expand Up @@ -1721,6 +1722,8 @@ class ActionReplaceCharacter extends BaseCommand {
text: toReplace.repeat(timesToRepeat),
range: new vscode.Range(position, endPos),
diff: PositionDiff.offset({ character: timesToRepeat - 1 }),
manuallySetCursorPositions:
vimState.dotCommandStatus === DotCommandStatus.Executing ? true : undefined,
});
}
}
Expand Down
1 change: 1 addition & 0 deletions src/actions/commands/insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class CommandInsertPreviousText extends BaseCommand {

vimState.recordedState.transformer.addTransformation({
type: 'replayRecordedState',
count: 1,
recordedState,
});
}
Expand Down
22 changes: 17 additions & 5 deletions src/actions/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ExCommandLine } from './../cmd_line/commandLine';
import { Cursor } from './../common/motion/cursor';
import { PositionDiff, earlierOf, sorted } from './../common/motion/position';
import { configuration } from './../configuration/configuration';
import { Mode, isVisualMode } from './../mode/mode';
import { DotCommandStatus, Mode, isVisualMode } from './../mode/mode';
import { Register, RegisterMode } from './../register/register';
import { VimState } from './../state/vimState';
import { TextEditor } from './../textEditor';
Expand Down Expand Up @@ -459,7 +459,10 @@ class IndentOperatorVisualAndVisualLine extends BaseOperator {

public async run(vimState: VimState, start: Position, end: Position): Promise<void> {
// Repeating this command with dot should apply the indent to the previous selection
if (vimState.isRunningDotCommand && vimState.dotCommandPreviousVisualSelection) {
if (
vimState.dotCommandStatus === DotCommandStatus.Executing &&
vimState.dotCommandPreviousVisualSelection
) {
if (vimState.cursorStartPosition.isAfter(vimState.cursorStopPosition)) {
const shiftSelectionByNum =
vimState.dotCommandPreviousVisualSelection.end.line -
Expand Down Expand Up @@ -492,7 +495,10 @@ class IndentOperatorVisualBlock extends BaseOperator {
* block formed by extending the cursor start position downward by the number of lines
* in the previous visual block selection.
*/
if (vimState.isRunningDotCommand && vimState.dotCommandPreviousVisualSelection) {
if (
vimState.dotCommandStatus === DotCommandStatus.Executing &&
vimState.dotCommandPreviousVisualSelection
) {
const shiftSelectionByNum = Math.abs(
vimState.dotCommandPreviousVisualSelection.end.line -
vimState.dotCommandPreviousVisualSelection.start.line,
Expand Down Expand Up @@ -549,7 +555,10 @@ class OutdentOperatorVisualAndVisualLine extends BaseOperator {

public async run(vimState: VimState, start: Position, end: Position): Promise<void> {
// Repeating this command with dot should apply the indent to the previous selection
if (vimState.isRunningDotCommand && vimState.dotCommandPreviousVisualSelection) {
if (
vimState.dotCommandStatus === DotCommandStatus.Executing &&
vimState.dotCommandPreviousVisualSelection
) {
if (vimState.cursorStartPosition.isAfter(vimState.cursorStopPosition)) {
const shiftSelectionByNum =
vimState.dotCommandPreviousVisualSelection.end.line -
Expand Down Expand Up @@ -585,7 +594,10 @@ class OutdentOperatorVisualBlock extends BaseOperator {
* block formed by extending the cursor start position downward by the number of lines
* in the previous visual block selection.
*/
if (vimState.isRunningDotCommand && vimState.dotCommandPreviousVisualSelection) {
if (
vimState.dotCommandStatus === DotCommandStatus.Executing &&
vimState.dotCommandPreviousVisualSelection
) {
const shiftSelectionByNum = Math.abs(
vimState.dotCommandPreviousVisualSelection.end.line -
vimState.dotCommandPreviousVisualSelection.start.line,
Expand Down
6 changes: 3 additions & 3 deletions src/actions/plugins/surround.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from '../motion';
import { PositionDiff, sorted } from './../../common/motion/position';
import { configuration } from './../../configuration/configuration';
import { Mode } from './../../mode/mode';
import { DotCommandStatus, Mode } from './../../mode/mode';
import { BaseCommand, RegisterAction } from './../base';
import { BaseOperator } from './../operator';

Expand Down Expand Up @@ -348,7 +348,7 @@ export class CommandSurroundAddSurroundingTag extends BaseCommand {

vimState.surround.replacement = 't';
const tagInput =
vimState.isRunningDotCommand || vimState.isReplayingMacro
vimState.dotCommandStatus === DotCommandStatus.Executing || vimState.isReplayingMacro
? this.recordedTag
: await this.readTag();

Expand Down Expand Up @@ -404,7 +404,7 @@ export class CommandSurroundAddSurroundingFunction extends BaseCommand {
this.keysPressed[this.keysPressed.length - 1] === 'F' ? '(' : ')';

const functionInput =
vimState.isRunningDotCommand || vimState.isReplayingMacro
vimState.dotCommandStatus === DotCommandStatus.Executing || vimState.isReplayingMacro
? this.recordedFunction
: await this.readFunction();

Expand Down
9 changes: 9 additions & 0 deletions src/cmd_line/commands/explore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { commands } from 'vscode';
import { VimState } from '../../state/vimState';
import { ExCommand } from '../../vimscript/exCommand';

export class ExploreCommand extends ExCommand {
async execute(vimState: VimState): Promise<void> {
await commands.executeCommand('workbench.view.explorer');
}
}
11 changes: 11 additions & 0 deletions src/mode/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ export enum NormalCommandState {
Finished,
}

export enum DotCommandStatus {
Waiting,
Executing,
Finished,
}

export enum ReplayMode {
Insert,
Replace,
}

/**
* Is the given mode visual, visual line, or visual block?
*/
Expand Down
Loading

0 comments on commit dbd0bd2

Please sign in to comment.