Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Status Bar Item #307

Closed
cemalgnlts opened this issue Jan 4, 2024 · 2 comments
Closed

Multiple Status Bar Item #307

cemalgnlts opened this issue Jan 4, 2024 · 2 comments

Comments

@cemalgnlts
Copy link

Hi,

I created a status bar item to open notifications:

await initialize({
  ...
});

// Notification status bar item.
const notifyService = await getService(INotificationService);

const getIcon = (dotIcon: boolean = false) => {
  const icon = ["bell"];

  if (notifyService.doNotDisturbMode) icon.push("-slash");
  if (dotIcon) icon.push("-dot");

  return `$(${icon.join("")})`;
};

const notifyItem = window.createStatusBarItem(StatusBarAlignment.Right, 1);
notifyItem.command = "notifications.showList";
notifyItem.name = "Notifications";
notifyItem.text = getIcon();

notifyService.onDidChangeDoNotDisturbMode(() => (notifyItem.text = getIcon()));
notifyService.onDidRemoveNotification(() => (notifyItem.text = getIcon()));
notifyService.onDidAddNotification(() => (notifyItem.text = getIcon(true)));

notifyItem.show();

This allows me to add a notification widget at the bottom right like in VSCode:
Screenshot 2024-01-04 15 26 58

I then try to create another one for my extension running in worker.

import { StatusBarAlignment, commands, window } from "vscode";

function activate() {
  addStatusBarItem();

  commands.registerCommand("esbuild.test", () => {
    console.log("OK");
  });
}

function addStatusBarItem() {
  const item = window.createStatusBarItem(StatusBarAlignment.Left, 1);
  item.command = "esbuild.test";
  item.name = "esbuild";
  item.text = "$(zap) Build";
  item.show();
}

export { activate };

Instead of adding more than one place, they share one place.

Screen.recording.2024-01-04.15.34.03.webm
@CGNonofr
Copy link
Contributor

CGNonofr commented Jan 4, 2024

Indeed, it looks like a bug in VSCode, here's the bug report: microsoft/vscode#201795

The workaround is to set the status bar item id

Here's the PR that adds the missing VSCode notification status bar item: #308

@cemalgnlts
Copy link
Author

Thanks!

@CGNonofr CGNonofr closed this as completed Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants