Skip to content

Commit 9c2f75a

Browse files
committed
Source file merger
1 parent 11f83e1 commit 9c2f75a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/app/src/components/workbench/source.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,12 @@ export class DevtoolsSource extends Element {
4141
}
4242

4343
#renderEditor (filePath: string, highlightLine?: number) {
44-
if (!this.sources) {
45-
return
46-
}
47-
44+
if (!this.sources) return
4845
const source = this.sources[filePath]
49-
if (!source) {
50-
return
51-
}
46+
if (!source) return
5247

5348
const container = this.shadowRoot?.querySelector('section') || this.shadowRoot?.querySelector('.cm-editor')
54-
if (!container) {
55-
return
56-
}
49+
if (!container) return
5750

5851
const opts: EditorViewConfig = {
5952
root: this.shadowRoot!,
@@ -64,14 +57,13 @@ export class DevtoolsSource extends Element {
6457
const editorView = new EditorView(opts)
6558
container.replaceWith(editorView.dom)
6659

67-
// Use CodeMirror API to select and scroll to the target line (1-based index)
6860
if (highlightLine && highlightLine > 0) {
6961
try {
70-
const lineInfo = editorView.state.doc.line(highlightLine) // 1-based
62+
const lineInfo = editorView.state.doc.line(highlightLine)
7163
requestAnimationFrame(() => {
7264
editorView.dispatch({
7365
selection: { anchor: lineInfo.from },
74-
effects: EditorView.scrollIntoView(lineInfo.from, { y: 'center' }) // center the line
66+
effects: EditorView.scrollIntoView(lineInfo.from, { y: 'center' })
7567
})
7668
})
7769
} catch { /* ignore */ }

packages/app/src/controller/DataManager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ export class DataManagerController implements ReactiveController {
141141
...this.consoleLogsContextProvider.value,
142142
...data as string[]
143143
])
144+
}
145+
else if (scope === 'sources') {
146+
const merged = {
147+
...(this.sourcesContextProvider.value || {}),
148+
...(data as Record<string, string>)
149+
}
150+
this.sourcesContextProvider.setValue(merged)
151+
console.debug('Merged sources keys', Object.keys(merged))
144152
} else {
145153
const provider = this[`${scope}ContextProvider`]
146154
provider.setValue(data as any)

0 commit comments

Comments
 (0)