Skip to content

Commit

Permalink
Fix bug in keyboard event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingislost committed Sep 9, 2021
1 parent e9aa4db commit e01dc4f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "workspace-picker",
"name": "Workspace Picker",
"version": "0.0.4",
"version": "0.0.5",
"minAppVersion": "0.9.12",
"description": "Quickly switch and manage workspaces",
"author": "NothingIsLost",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-workspace-picker",
"version": "0.0.4",
"version": "0.0.5",
"description": "Quickly switch and manage workspaces",
"main": "main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.0.5": "0.9.12",
"0.0.4": "0.9.12",
"0.0.3": "0.9.12",
"0.0.2": "0.9.12",
Expand Down
11 changes: 5 additions & 6 deletions workspace-picker-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare module "obsidian" {
saveWorkspace(workspaceName: string): void;
loadWorkspace(workspaceName: string): void;
activeWorkspace: string;
workspaces: { [x: string]: { [x: string]: any; active: any; }; };
workspaces: { [x: string]: { [x: string]: any; active: any; }; }; // TODO: fix this inferred typing
}
}

Expand Down Expand Up @@ -164,15 +164,15 @@ export default class WorkspacePickerPluginModal extends FuzzySuggestModal<string
}

useSelectedItem = function (evt: MouseEvent | KeyboardEvent) {
let workspaceName = this.inputEl.value ? this.inputEl.value : null;
let workspaceName = this.inputEl.value ? this.inputEl.value : this.chooser.values[this.chooser.selectedItem].item;
if (!this.values && workspaceName && evt.shiftKey) {
this.saveAndStay();
this.setWorkspace(workspaceName);
this.close();
return !1;
} else if (!this.values) return !1;
var item = this.values ? this.values[this.selectedItem] : workspaceName;
return void 0 !== item && (this.chooser.selectSuggestion(item, evt), !0);
} else if (!this.chooser.values) return !1;
var item = this.chooser.values ? this.chooser.values[this.chooser.selectedItem] : workspaceName;
return void 0 !== item && (this.selectSuggestion(item, evt), !0);
};

saveAndStay() {
Expand Down Expand Up @@ -230,7 +230,6 @@ export default class WorkspacePickerPluginModal extends FuzzySuggestModal<string
if (evt.shiftKey && !evt.altKey) modifiers = "Shift";
else if (evt.altKey && !evt.shiftKey) modifiers = "Alt";
else modifiers = "";

if (modifiers === "Shift") this.saveAndStay(), this.setWorkspace(item), this.close();
if (modifiers === "Alt") this.saveAndSwitch(), this.setWorkspace(item);
else this.setWorkspace(item);
Expand Down

0 comments on commit e01dc4f

Please sign in to comment.