Skip to content

Commit

Permalink
feat: hide status bar when fire closeFileEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoluoboding committed Sep 10, 2020
1 parent 3053818 commit a705b56
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/FolderSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,20 @@ export class FolderSize implements vscode.Disposable {
}
}

private initData(): void {
this.folderInfo = { total: 0, count: 0 }
this.fileSize = ''
this.folderSize = ''
this.folderMap = new Map()
}

private initialize(): void {
this._config = Utility.getConfiguration(Constants.pluginName)
}

private resetFolderInfo(): Promise<folderSizeMeta> {
return new Promise((resolve) => {
this.folderInfo = { total: 0, count: 0 }
this.fileSize = ''
this.folderSize = ''
this.folderMap = new Map()
this.initData()
resolve(this.folderInfo)
})
}
Expand Down Expand Up @@ -159,6 +163,7 @@ export class FolderSize implements vscode.Disposable {
}

private stop(): void {
this.initData()
this.sbi.hide()
}
}
17 changes: 11 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@ export function activate({ subscriptions }: vscode.ExtensionContext) {
const folderSize = new FolderSize()

// register a command that is invoked when the status bar
const showInformation = vscode.commands.registerCommand(Constants.statusBarCommand, () => {
const showInformationCommand = vscode.commands.registerCommand(Constants.statusBarCommand, () => {
folderSize.showInformation()
})

// const changeFile = vscode.workspace.onDidChangeTextDocument((e) =>
// folderSize.getFileSize(e.document)
// )

const saveFile = vscode.workspace.onDidSaveTextDocument((document) =>
const saveFileEvent = vscode.workspace.onDidSaveTextDocument((document) =>
folderSize.getFileSize(document)
)

const openFile = vscode.workspace.onDidOpenTextDocument((document) =>
const openFileEvent = vscode.workspace.onDidOpenTextDocument((document) =>
folderSize.getFileSize(document)
)

const closeFileEvent = vscode.workspace.onDidCloseTextDocument((document) =>
folderSize.dispose()
)

// register some listener that make sure the status bar item always up-to-date
subscriptions.push(folderSize.sbi)
subscriptions.push(showInformation)
subscriptions.push(showInformationCommand)
// subscriptions.push(changeFile)
subscriptions.push(saveFile)
subscriptions.push(openFile)
subscriptions.push(saveFileEvent)
subscriptions.push(openFileEvent)
subscriptions.push(closeFileEvent)
}
Binary file added vscode-folder-size-0.0.3.vsix
Binary file not shown.

0 comments on commit a705b56

Please sign in to comment.