Skip to content

Commit

Permalink
fix: some tip name
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Apr 15, 2023
1 parent 5b9206c commit 87235d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
12 changes: 11 additions & 1 deletion packages/varlet-vscode-extension/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PLAYGROUND } from './constant'
import { PLAYGROUND, DOCUMENTATION_EN, DOCUMENTATION_ZH } from './constant'
import { commands, window, Selection, env, Uri, Range } from 'vscode'
import { getLanguage } from './env'

function openPlayground(wrapTemplate = false) {
const { activeTextEditor } = window
Expand All @@ -26,6 +27,11 @@ function openPlayground(wrapTemplate = false) {
env.openExternal(Uri.parse(`${PLAYGROUND}#${hash}`))
}

function openDocumentation() {
const language = getLanguage()
env.openExternal(Uri.parse(language === 'en-US' ? DOCUMENTATION_EN : DOCUMENTATION_ZH))
}

export function registerCommands() {
commands.registerCommand('varlet.move-cursor', (characterDelta: number) => {
const active = window.activeTextEditor!.selection.active!
Expand All @@ -37,6 +43,10 @@ export function registerCommands() {
openPlayground()
})

commands.registerCommand('varlet.open-documentation', () => {
openDocumentation()
})

commands.registerCommand('varlet.open-playground-and-wrap-template-tag', () => {
openPlayground(true)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function activate(context: ExtensionContext) {
registerCommands()
registerCompletions(context)
registerHover(context)
registerStatusBarItems(context)
registerStatusBarItems()
}

export function deactivate() {}
13 changes: 2 additions & 11 deletions packages/varlet-vscode-extension/src/statusBarItems.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { StatusBarAlignment, window, commands, env, Uri, type ExtensionContext } from 'vscode'
import { DOCUMENTATION_EN, DOCUMENTATION_ZH, PLAYGROUND } from './constant'
import { getLanguage } from './env'
import { StatusBarAlignment, window } from 'vscode'

export function registerStatusBarItems(context: ExtensionContext) {
const language = getLanguage()
export function registerStatusBarItems() {
const statusBarList = [
{
name: 'Varlet Documentation',
url: language === 'en-US' ? DOCUMENTATION_EN : DOCUMENTATION_ZH,
priority: 0,
command: 'varlet.open-documentation',
tooltip: 'Open Varlet Documentation',
},
{
name: 'Varlet Playground',
url: PLAYGROUND,
priority: 0,
command: 'varlet.open-playground',
tooltip: 'Open Varlet Playground',
Expand All @@ -26,9 +21,5 @@ export function registerStatusBarItems(context: ExtensionContext) {
statusBar.text = item.name
statusBar.tooltip = item.tooltip
statusBar.show()
const disposable = commands.registerCommand(item.command, () => {
env.openExternal(Uri.parse(item.url))
})
context.subscriptions.push(disposable)
})
}

0 comments on commit 87235d2

Please sign in to comment.