-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
检查列表显示位置变为临时文件, 修复ignore包含模式BUG(!), 打包到单文件-准备Web端
- Loading branch information
1 parent
3244a31
commit 5b2f5f6
Showing
40 changed files
with
999 additions
and
544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"format-files-by-ignores": minor | ||
--- | ||
|
||
检查列表显示位置变为临时文件, 修复 ignore 包含模式 BUG(!), 打包到单文件-准备 Web 端 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ images | |
.formatignore | ||
LICENSE | ||
*.png | ||
*.md | ||
*.md | ||
*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { Config } from '@/config'; | ||
import { EAborted } from '@/error'; | ||
import log from '@/log'; | ||
import msg from '@components/msg'; | ||
import { ExtensionContext, commands, window } from 'vscode'; | ||
|
||
/** | ||
* 配置 | ||
*/ | ||
export interface CmdOptions { | ||
/** | ||
* 注册 key | ||
*/ | ||
key: string | ||
} | ||
|
||
/** | ||
* 通用命令 | ||
*/ | ||
export default abstract class ICmd { | ||
|
||
constructor(protected options: CmdOptions) { } | ||
|
||
/** | ||
* 命令回调 | ||
* @param args 任意回调参数 | ||
*/ | ||
abstract run(...args: unknown[]): Promise<void>; | ||
|
||
/** | ||
* 回调抛出异常时执行 | ||
* @param error 异常 | ||
*/ | ||
async catch(error: Error) { | ||
if (error instanceof EAborted) { | ||
msg.showWarningMessage(error.message); | ||
return; | ||
} | ||
window.showErrorMessage(error.message); | ||
log.error(error.stack ?? error.message); | ||
} | ||
|
||
/** | ||
* 回调执行完后执行 | ||
*/ | ||
async finally() { } | ||
|
||
/** | ||
* 注册指令 | ||
* @param context 上下文 | ||
*/ | ||
async activate(context: ExtensionContext) { | ||
log.debug('Register command:', this.options.key); | ||
|
||
const callback = async (...args: unknown[]) => { | ||
log.debug('Format config:', JSON.stringify(Config.get)); | ||
log.debug('Command:', this.options.key, 'callback args:', args); | ||
try { | ||
return await this.run(...args); | ||
} catch (error) { | ||
await this.catch(error as Error); | ||
} finally { | ||
await this.finally(); | ||
} | ||
}; | ||
|
||
const disposable = commands.registerCommand(this.options.key, callback); | ||
|
||
context.subscriptions.push(disposable); | ||
} | ||
|
||
/** | ||
* 注销指令 | ||
*/ | ||
async deactivate() { | ||
log.debug('Deactivate command:', this.options.key); | ||
} | ||
} |
Oops, something went wrong.