Skip to content

Commit

Permalink
Fix bug in workspace comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingislost committed Sep 10, 2021
1 parent d7b7811 commit a12f9b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export default class WorkspacePicker extends Plugin {
const workspacePickerStatusBarItem = this.addStatusBarItem();
this.workspacePlugin = this.app.internalPlugins.getPluginById("workspaces").instance as WorkspacePluginInstance;

const icon = workspacePickerStatusBarItem.createDiv("icon");
const icon = workspacePickerStatusBarItem.createSpan("status-bar-item-segment icon");
setIcon(icon, "pane-layout"); //pane-layout

this.changeWorkspaceButton = workspacePickerStatusBarItem.createDiv({
cls: "status-bar-item mod-clickable",
this.changeWorkspaceButton = workspacePickerStatusBarItem.createSpan({
cls: "status-bar-item-segment name",
text: this.workspacePlugin.activeWorkspace + (this.isWorkspaceModified() ? "*" : ""),
prepend: false,
});
Expand All @@ -48,12 +48,12 @@ export default class WorkspacePicker extends Plugin {

isWorkspaceModified = () => {
try { // this is to catch an on-resize related error when loading a new workspace
var {...currentWorkspace } = this.app.workspace.getLayout();
var currentWorkspace = JSON.parse(JSON.stringify(this.app.workspace.getLayout()))
} catch {
return false;
} // remove the active property since we don't need it for comparison
var activeWorkspaceName = this.workspacePlugin.activeWorkspace, // active workspace name
{...savedWorkspace } = this.workspacePlugin.workspaces[activeWorkspaceName];
savedWorkspace = JSON.parse(JSON.stringify(this.workspacePlugin.workspaces[activeWorkspaceName]))
deleteProp(savedWorkspace, ["active", "dimension", "width"]);
deleteProp(currentWorkspace, ["active", "dimension", "width"]);
return !deepEqual(currentWorkspace, savedWorkspace); // via the fast-equals package
Expand Down
17 changes: 9 additions & 8 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@
fill: var(--text-normal);
}

.status-bar .plugin-workspace-picker > .status-bar-item {
display: inline-block;
padding: 0;
margin: 0;
vertical-align: middle;
.status-bar .plugin-workspace-picker .status-bar-item-segment.icon {
/* margin-right: 2px;
vertical-align: middle; */
position: absolute;
/* margin-top: 1px; */
}

.status-bar .plugin-workspace-picker .icon {
display: inline-block;
.status-bar .plugin-workspace-picker .status-bar-item-segment.name {
margin-left: 1.4em;
}

.status-bar .plugin-workspace-picker .icon svg {
height: 16px;
width: 16px;
vertical-align: text-top;
margin-right: 2px;
}

.workspace-picker-modal .workspace-item[contenteditable="true"] {
Expand Down

0 comments on commit a12f9b0

Please sign in to comment.