mirror of
https://github.com/Eugeny/tabby
synced 2024-12-13 14:52:45 +00:00
fixed linkifier plugin not working with multiple providers
This commit is contained in:
parent
07b0aa3d70
commit
a29a552afc
1 changed files with 35 additions and 20 deletions
|
@ -29,27 +29,42 @@ export class LinkHighlighterDecorator extends TerminalDecorator {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const handler of this.handlers) {
|
const openLink = async uri => {
|
||||||
const getLink = async uri => handler.convert(uri, tab)
|
for (const handler of this.handlers) {
|
||||||
const openLink = async uri => handler.handle(await getLink(uri), tab)
|
if (!handler.regex.test(uri)) {
|
||||||
|
continue
|
||||||
const addon = new WebLinksAddon(
|
}
|
||||||
async (event, uri) => {
|
if (!await handler.verify(await handler.convert(uri, tab), tab)) {
|
||||||
if (!this.willHandleEvent(event)) {
|
continue
|
||||||
return
|
}
|
||||||
}
|
handler.handle(await handler.convert(uri, tab), tab)
|
||||||
if (!await handler.verify(await handler.convert(uri, tab), tab)) {
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
openLink(uri)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
urlRegex: handler.regex,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
tab.frontend.xterm.loadAddon(addon)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let regex = new RegExp('')
|
||||||
|
const regexSource = this.handlers.map(x => `(${x.regex.source})`).join('|')
|
||||||
|
try {
|
||||||
|
regex = new RegExp(regexSource)
|
||||||
|
console.debug('Linkifier regexp', regex)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Could not build regex for your link handlers:', error)
|
||||||
|
console.error('Regex source was:', regexSource)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const addon = new WebLinksAddon(
|
||||||
|
async (event, uri) => {
|
||||||
|
if (!this.willHandleEvent(event)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
openLink(uri)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
urlRegex: regex,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
tab.frontend.xterm.loadAddon(addon)
|
||||||
}
|
}
|
||||||
|
|
||||||
private willHandleEvent (event: MouseEvent) {
|
private willHandleEvent (event: MouseEvent) {
|
||||||
|
|
Loading…
Reference in a new issue