Skip to content

Commit

Permalink
fix: fixes #2296. status bar was not updating properly when recording…
Browse files Browse the repository at this point in the history
… macros
  • Loading branch information
jpoon committed Jan 17, 2018
1 parent f07d46f commit fd9d05b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/cmd_line/commandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class CommandLine {
} catch (e) {
console.log(e);
if (e instanceof VimError) {
StatusBar.SetText(`${e.toString()}. ${command}`, vimState.currentMode, true);
StatusBar.SetText(`${e.toString()}. ${command}`, vimState.currentMode, vimState.isRecordingMacro, true);
} else {
util.showError(e.toString());
}
Expand Down
8 changes: 4 additions & 4 deletions src/cmd_line/commands/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export class WriteCommand extends node.CommandBase {
if (!e) {
return this.save(vimState);
}
StatusBar.SetText(e.message, vimState.currentMode, true);
StatusBar.SetText(e.message, vimState.currentMode, vimState.isRecordingMacro, true);
return;
});
} else {
StatusBar.SetText(accessErr.message, vimState.currentMode, true);
StatusBar.SetText(accessErr.message, vimState.currentMode, vimState.isRecordingMacro, true);
}
}
}
Expand All @@ -83,9 +83,9 @@ export class WriteCommand extends node.CommandBase {
'L ' +
vimState.editor.document.getText().length +
'C written';
StatusBar.SetText(text, vimState.currentMode, true);
StatusBar.SetText(text, vimState.currentMode, vimState.isRecordingMacro, true);
},
e => StatusBar.SetText(e, vimState.currentMode, true)
e => StatusBar.SetText(e, vimState.currentMode, vimState.isRecordingMacro, true)
);
}
}
5 changes: 3 additions & 2 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1388,13 +1388,14 @@ export class ModeHandler implements vscode.Disposable {
text.push(this.currentMode.getStatusBarCommandText(this.vimState));
}


if (this.vimState.isRecordingMacro) {
const macroText = 'Recording @' + this.vimState.recordedMacro.registerName;
text.push(macroText);
}

let forceUpdate = this.currentMode.name === ModeName.SearchInProgressMode;
StatusBar.SetText(text.join(' '), this.currentMode.name, forceUpdate);
let forceUpdate = this.currentMode.name === ModeName.SearchInProgressMode || this.vimState.isRecordingMacro;
StatusBar.SetText(text.join(' '), this.currentMode.name, this.vimState.isRecordingMacro, forceUpdate);
}

async handleMultipleKeyEvents(keys: string[]): Promise<void> {
Expand Down
10 changes: 8 additions & 2 deletions src/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ import { ModeName } from './mode/mode';
class StatusBarClass implements vscode.Disposable {
private _statusBarItem: vscode.StatusBarItem;
private _prevModeName: ModeName | undefined;
private _isRecordingMacro: boolean;

constructor() {
this._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
this._prevModeName = undefined;
this._isRecordingMacro = false;
}

public SetText(text: string, mode: ModeName, forceShow: boolean = false) {
if (mode !== this._prevModeName || forceShow) {
public SetText(text: string, mode: ModeName, isRecordingMacro: boolean, forceShow: boolean = false) {
let updateStatusBar = forceShow || this._prevModeName !== mode || this._isRecordingMacro !== isRecordingMacro;

this._prevModeName = mode;
this._isRecordingMacro = isRecordingMacro;

if (updateStatusBar) {
this._statusBarItem.text = text || '';
this._statusBarItem.show();
}
Expand Down
1 change: 1 addition & 0 deletions test/configuration/notation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ suite('Notation', () => {
'<CmD+a>': '<D-a>',
eScapE: '<Esc>',
'<LeAder>': '//',
'leader': '//',
};

for (const test in testCases) {
Expand Down

0 comments on commit fd9d05b

Please sign in to comment.