Skip to content

Commit

Permalink
Prefix source map location with plugin ID
Browse files Browse the repository at this point in the history
Signed-off-by: William So <polyipseity@gmail.com>
  • Loading branch information
polyipseity committed Aug 14, 2023
1 parent 8452b18 commit 7981fe3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-impalas-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"obsidian-terminal": patch
---

Prefix source map location with plugin ID.
10 changes: 6 additions & 4 deletions sources/terminal/pseudoterminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export class DeveloperConsolePseudoterminal
public constructor(
protected readonly self0: () => Window & typeof globalThis,
protected readonly log: Log,
protected readonly sourceRoot = "",
) {
super()
const { terminals } = this
Expand Down Expand Up @@ -401,7 +402,7 @@ export class DeveloperConsolePseudoterminal
}

protected async eval(): Promise<void> {
const { buffer, context, lock, self0, terminals } = this,
const { buffer, context, lock, self0, sourceRoot, terminals } = this,
self1 = self0(),
code = await lock.acquire(
DeveloperConsolePseudoterminal.syncLock,
Expand Down Expand Up @@ -476,7 +477,8 @@ export class DeveloperConsolePseudoterminal
DeveloperConsolePseudoterminal.contextVar,
attachFunctionSourceMap(ctor, script, {
deletions,
source: "<stdin>",
file: "<stdin>",
sourceRoot: `${sourceRoot}${sourceRoot && "/"}<stdin>`,
}),
)(context)
}
Expand Down Expand Up @@ -625,10 +627,10 @@ export namespace DeveloperConsolePseudoterminal {
public constructor(protected readonly context: TerminalPlugin) { super() }

protected override async load0(): Promise<Manager.Type> {
const { context: { earlyPatch: { onLoaded } } } = this,
const { context: { earlyPatch: { onLoaded }, manifest: { id } } } = this,
{ log } = await onLoaded,
ret = lazyInit(() => new RefPsuedoterminal(
new DeveloperConsolePseudoterminal(activeSelf, log),
new DeveloperConsolePseudoterminal(activeSelf, log, `plugin:${id}`),
))
this.register(async () => ret().kill())
// Cannot use `lazyProxy`, the below `return` accesses `ret.then`
Expand Down

0 comments on commit 7981fe3

Please sign in to comment.