diff --git a/CHANGELOG.md b/CHANGELOG.md index bb94e152..2390072a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ All notable changes to the Keyboard Macro Bata extension will be documented in t - Added `sequence` argument support to the playback command. [#41](https://github.com/tshino/vscode-kb-macro/pull/41) - Update - Updated keymap wrapper for Awesome Emacs Keymap (v0.39.0). +- Fix + - Fixed uncaught errors 'Cannot read property 'textEditor' of undefined'. [#47](https://github.com/tshino/vscode-kb-macro/pull/47) ### [0.10.0] - 2022-01-28 - Feature diff --git a/src/extension.js b/src/extension.js index 6e0a9863..9057d16f 100644 --- a/src/extension.js +++ b/src/extension.js @@ -117,8 +117,8 @@ function activate(context) { ); addEventListener( vscode.window.onDidChangeActiveTextEditor, - function(event) { - helperContext.processActiveTextEditorChangeEvent(event); + function(textEditor) { + helperContext.processActiveTextEditorChangeEvent(textEditor); } ); addEventListener( diff --git a/src/helper_context.js b/src/helper_context.js index f68fd07c..6dfae2da 100644 --- a/src/helper_context.js +++ b/src/helper_context.js @@ -33,8 +33,8 @@ const HelperContext = function() { const reset = function(textEditor) { update(textEditor); }; - const processActiveTextEditorChangeEvent = function(event) { - update(event.textEditor); + const processActiveTextEditorChangeEvent = function(textEditor) { + update(textEditor); }; const processSelectionChangeEvent = function(event) { update(event.textEditor); diff --git a/test/suite/helper_context.test.js b/test/suite/helper_context.test.js index 7012a6c7..ab2ebfdd 100644 --- a/test/suite/helper_context.test.js +++ b/test/suite/helper_context.test.js @@ -30,8 +30,7 @@ describe('HelperContext', () => { const textEditor1 = { selections: [ new vscode.Selection(2, 4, 2, 4) ] }; const textEditor2 = { selections: [ new vscode.Selection(3, 0, 3, 0) ] }; helperContext.reset(textEditor1); - const event = { textEditor: textEditor2 }; - helperContext.processActiveTextEditorChangeEvent(event); + helperContext.processActiveTextEditorChangeEvent(textEditor2); assert.strictEqual(helperContext.getContext(HeadOfLine), true); }); });