Skip to content

Commit

Permalink
fix: make hover more make sense
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 11, 2019
1 parent da2fdcb commit a161fc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/editor/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ export function createTable (visibleLocales: string[], records: Record<string, L
return `| | | | | |\n|---|---:|---|---|---:|\n${transTable}\n| | | | | |`
}

export function createHover (keypath: string, maxLength = 0) {
export function createHover (keypath: string, maxLength = 0, mainLocale?: string) {
const loader = CurrentFile.loader
const records = loader.getTranslationsByKey(keypath)
const displayLocale = Config.displayLanguage
mainLocale = mainLocale || Config.displayLanguage

const locales = Global.visibleLocales.filter(i => i !== displayLocale)
const locales = Global.visibleLocales.filter(i => i !== mainLocale)
const table1 = createTable(locales, records, maxLength)
const table2 = createTable([displayLocale], records, maxLength)
const table2 = createTable([mainLocale], records, maxLength)
const markdown = `${table1}\n\n-----\n\n${table2}`

const markdownText = new MarkdownString(markdown)
Expand Down
2 changes: 1 addition & 1 deletion src/editor/localeAnnotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const localeAnnotation: ExtensionModule = (ctx) => {
fontStyle: 'normal',
},
},
hoverMessage: createHover(key, maxLength),
hoverMessage: createHover(key, maxLength, file.locale),
}

if (currentText)
Expand Down

0 comments on commit a161fc5

Please sign in to comment.