Skip to content

Commit

Permalink
feat: status bar api
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Jun 5, 2023
1 parent 3b62f16 commit 220a93f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/vscode-services/extHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { ExtHostOutputService, IExtHostOutputService } from 'vs/workbench/api/co
import { ExtHostTreeViews } from 'vs/workbench/api/common/extHostTreeViews'
import { ExtHostStorage } from 'vs/workbench/api/common/extHostStorage'
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'
import { ExtHostStatusBar } from 'vs/workbench/api/common/extHostStatusBar'
import 'vs/workbench/api/browser/mainThreadLocalization'
import 'vs/workbench/api/browser/mainThreadCommands'
import 'vs/workbench/api/browser/mainThreadWindow'
Expand All @@ -83,6 +84,7 @@ import 'vs/workbench/api/browser/mainThreadOutputService'
import 'vs/workbench/api/browser/mainThreadSaveParticipant'
import 'vs/workbench/api/browser/mainThreadTreeViews'
import 'vs/workbench/api/browser/mainThreadStorage'
import 'vs/workbench/api/browser/mainThreadStatusBar'
import * as errors from 'vs/base/common/errors'
import { Barrier } from 'vs/base/common/async'
import { unsupported } from '../tools'
Expand Down Expand Up @@ -351,6 +353,7 @@ async function createExtHostServices () {
const extHostBulkEdits = new ExtHostBulkEdits(rpcProtocol, extHostDocumentsAndEditors)
const extHostClipboard = new ExtHostClipboard(mainContext)
const extHostMessageService = new ExtHostMessageService(rpcProtocol, logService)
const extHostStatusBar = new ExtHostStatusBar(rpcProtocol, extHostCommands.converter)

// Register API-ish commands
ExtHostApiCommands.register(extHostCommands)
Expand Down Expand Up @@ -412,7 +415,8 @@ async function createExtHostServices () {
extHostOutputService,
extHostTreeViews,
extHostStorage,
extHostLocalization
extHostLocalization,
extHostStatusBar
}
}

Expand Down
25 changes: 23 additions & 2 deletions src/vscode-services/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,29 @@ export default function create (getExtension: () => IExtensionDescription, works
showOpenDialog: unsupported,
showSaveDialog: unsupported,
createWebviewPanel: unsupported,
setStatusBarMessage: unsupported,
createStatusBarItem: unsupported,
createStatusBarItem (alignmentOrId?: vscode.StatusBarAlignment | string, priorityOrAlignment?: number | vscode.StatusBarAlignment, priorityArg?: number): vscode.StatusBarItem {
const { extHostStatusBar } = getExtHostServices()
const extension = getExtension()
let id: string | undefined
let alignment: number | undefined
let priority: number | undefined

if (typeof alignmentOrId === 'string') {
id = alignmentOrId
alignment = priorityOrAlignment
priority = priorityArg
} else {
alignment = alignmentOrId
priority = priorityOrAlignment
}

return extHostStatusBar.createStatusBarEntry(extension, id, alignment, priority)
},
setStatusBarMessage (text: string, timeoutOrThenable?: number | Thenable<unknown>): vscode.Disposable {
const { extHostStatusBar } = getExtHostServices()

return extHostStatusBar.setStatusBarMessage(text, timeoutOrThenable)
},
createTerminal: unsupported,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
registerTreeDataProvider (viewId: string, treeDataProvider: vscode.TreeDataProvider<any>): vscode.Disposable {
Expand Down

0 comments on commit 220a93f

Please sign in to comment.