@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22import { NodeBase } from "./models/nodeBase" ;
33
44import { AtelierAPI } from "../api" ;
5- import { config , OBJECTSCRIPT_FILE_SCHEMA , projectsExplorerProvider } from "../extension" ;
5+ import { config , documentContentProvider , OBJECTSCRIPT_FILE_SCHEMA , projectsExplorerProvider } from "../extension" ;
66import { WorkspaceNode } from "./models/workspaceNode" ;
77import { outputChannel } from "../utils" ;
88import { DocumentContentProvider } from "../providers/DocumentContentProvider" ;
@@ -47,13 +47,25 @@ export function registerExplorerOpen(): vscode.Disposable {
4747 "vscode-objectscript.explorer.open" ,
4848 async function ( uri : vscode . Uri , project ?: string , fullName ?: string ) {
4949 let usePreview = < boolean > vscode . workspace . getConfiguration ( "workbench.editor" ) . get ( "enablePreview" ) ;
50-
51- if ( usePreview ) {
52- usePreview = ! wasDoubleClick ( uri ) ;
53- }
50+ const double = wasDoubleClick ( uri ) ;
51+ if ( usePreview ) usePreview = ! double ;
5452
5553 try {
5654 if ( uri . scheme === OBJECTSCRIPT_FILE_SCHEMA ) {
55+ const uriString = uri . toString ( ) ;
56+ if (
57+ ! double &&
58+ vscode . workspace . textDocuments . some ( ( d ) => d . uri . toString ( ) == uriString ) &&
59+ ! vscode . window . tabGroups . all . some ( ( tg ) =>
60+ tg . tabs . some ( ( t ) => t . input instanceof vscode . TabInputText && t . input . uri . toString ( ) == uriString )
61+ )
62+ ) {
63+ // Force an refresh from the server if the document was "closed", then "re-opened".
64+ // We define "closed" as "not in any tab", but still in VS Code's memory.
65+ // We don't need to do this if the document is not in VS Code's memory
66+ // because in that case the contents will be fetched from the server.
67+ documentContentProvider . update ( uri ) ;
68+ }
5769 // This scheme is implemented by our DocumentContentProvider, which always returns text.
5870 // If the server supplied binary data our provider substitutes a text explanation of how to work with binary content.
5971 await vscode . window . showTextDocument ( uri , { preview : usePreview } ) ;
0 commit comments