( documentOrUri: TextDocument | Uri, columnOrOptions?: ViewColumn | TextDocumentShowOptions, _preserveFocus?: boolean, )
| 149 | } |
| 150 | |
| 151 | async showTextDocument( |
| 152 | documentOrUri: TextDocument | Uri, |
| 153 | columnOrOptions?: ViewColumn | TextDocumentShowOptions, |
| 154 | _preserveFocus?: boolean, |
| 155 | ): Promise<TextEditor> { |
| 156 | // Mock implementation for CLI |
| 157 | // In a real VSCode environment, this would open the document in an editor |
| 158 | const uri = documentOrUri instanceof Uri ? documentOrUri : documentOrUri.uri |
| 159 | logs.debug(`showTextDocument called for: ${uri?.toString() || "unknown"}`, "VSCode.Window") |
| 160 | |
| 161 | // Create a placeholder editor first so it's in visibleTextEditors when onDidOpenTextDocument fires |
| 162 | const placeholderEditor: TextEditor = { |
| 163 | document: { uri } as TextDocument, |
| 164 | selection: new Selection(new Position(0, 0), new Position(0, 0)), |
| 165 | selections: [new Selection(new Position(0, 0), new Position(0, 0))], |
| 166 | visibleRanges: [new Range(new Position(0, 0), new Position(0, 0))], |
| 167 | options: {}, |
| 168 | viewColumn: typeof columnOrOptions === "number" ? columnOrOptions : ViewColumn.One, |
| 169 | edit: () => Promise.resolve(true), |
| 170 | insertSnippet: () => Promise.resolve(true), |
| 171 | setDecorations: () => {}, |
| 172 | revealRange: () => {}, |
| 173 | show: () => {}, |
| 174 | hide: () => {}, |
| 175 | } |
| 176 | |
| 177 | // Add placeholder to visible editors BEFORE opening document |
| 178 | this.visibleTextEditors.push(placeholderEditor) |
| 179 | logs.debug( |
| 180 | `Placeholder editor added to visibleTextEditors, total: ${this.visibleTextEditors.length}`, |
| 181 | "VSCode.Window", |
| 182 | ) |
| 183 | |
| 184 | // If we have a URI, open the document (this will fire onDidOpenTextDocument) |
| 185 | let document: TextDocument | Uri = documentOrUri |
| 186 | if (documentOrUri instanceof Uri && this._workspace) { |
| 187 | logs.debug("Opening document via workspace.openTextDocument", "VSCode.Window") |
| 188 | document = await this._workspace.openTextDocument(uri) |
| 189 | logs.debug("Document opened successfully", "VSCode.Window") |
| 190 | |
| 191 | // Update the placeholder editor with the real document |
| 192 | placeholderEditor.document = document |
| 193 | } |
| 194 | |
| 195 | // Fire events immediately using setImmediate |
| 196 | setImmediate(() => { |
| 197 | logs.debug("Firing onDidChangeVisibleTextEditors event", "VSCode.Window") |
| 198 | this._onDidChangeVisibleTextEditors.fire(this.visibleTextEditors) |
| 199 | logs.debug("onDidChangeVisibleTextEditors event fired", "VSCode.Window") |
| 200 | }) |
| 201 | |
| 202 | logs.debug("Returning editor from showTextDocument", "VSCode.Window") |
| 203 | return placeholderEditor |
| 204 | } |
| 205 | |
| 206 | registerWebviewViewProvider( |
| 207 | viewId: string, |
no test coverage detected