()
| 380 | } |
| 381 | |
| 382 | async initTerminal() { |
| 383 | const copyOnSelectAtom = getSettingsKeyAtom("term:copyonselect"); |
| 384 | const trimTrailingWhitespaceAtom = getSettingsKeyAtom("term:trimtrailingwhitespace"); |
| 385 | this.toDispose.push(this.terminal.onData(this.handleTermData.bind(this))); |
| 386 | this.toDispose.push( |
| 387 | this.terminal.onSelectionChange( |
| 388 | debounce(50, () => { |
| 389 | if (!globalStore.get(copyOnSelectAtom)) { |
| 390 | return; |
| 391 | } |
| 392 | // Don't copy-on-select when the search bar has focus — navigating |
| 393 | // search results changes the terminal selection programmatically. |
| 394 | const active = document.activeElement; |
| 395 | if (active != null && active.closest(".search-container") != null) { |
| 396 | return; |
| 397 | } |
| 398 | let selectedText = this.terminal.getSelection(); |
| 399 | if (selectedText.length > 0) { |
| 400 | if (globalStore.get(trimTrailingWhitespaceAtom) !== false) { |
| 401 | selectedText = trimTerminalSelection(selectedText); |
| 402 | } |
| 403 | navigator.clipboard.writeText(selectedText); |
| 404 | } |
| 405 | }) |
| 406 | ) |
| 407 | ); |
| 408 | if (this.onSearchResultsDidChange != null) { |
| 409 | this.toDispose.push(this.searchAddon.onDidChangeResults(this.onSearchResultsDidChange.bind(this))); |
| 410 | } |
| 411 | |
| 412 | this.mainFileSubject = getFileSubject(this.getZoneId(), TermFileName); |
| 413 | this.mainFileSubject.subscribe(this.handleNewFileSubjectData.bind(this)); |
| 414 | |
| 415 | try { |
| 416 | const rtInfo = await RpcApi.GetRTInfoCommand(TabRpcClient, { |
| 417 | oref: WOS.makeORef("block", this.blockId), |
| 418 | }); |
| 419 | let shellState: ShellIntegrationStatus = null; |
| 420 | |
| 421 | if (rtInfo && rtInfo["shell:integration"]) { |
| 422 | shellState = rtInfo["shell:state"] as ShellIntegrationStatus; |
| 423 | globalStore.set(this.shellIntegrationStatusAtom, shellState || null); |
| 424 | } else { |
| 425 | globalStore.set(this.shellIntegrationStatusAtom, null); |
| 426 | } |
| 427 | |
| 428 | const lastCmd = rtInfo ? rtInfo["shell:lastcmd"] : null; |
| 429 | const isCC = shellState === "running-command" && isClaudeCodeCommand(lastCmd); |
| 430 | globalStore.set(this.lastCommandAtom, lastCmd || null); |
| 431 | globalStore.set(this.claudeCodeActiveAtom, isCC); |
| 432 | } catch (e) { |
| 433 | console.log("Error loading runtime info:", e); |
| 434 | } |
| 435 | |
| 436 | try { |
| 437 | await this.loadInitialTerminalData(); |
| 438 | } finally { |
| 439 | this.loaded = true; |
nothing calls this directly
no test coverage detected