@@ -2,7 +2,7 @@ import * as vscode from "vscode";
2
2
import { NodeBase } from "./models/nodeBase" ;
3
3
4
4
import { AtelierAPI } from "../api" ;
5
- import { config , OBJECTSCRIPT_FILE_SCHEMA , projectsExplorerProvider } from "../extension" ;
5
+ import { config , documentContentProvider , OBJECTSCRIPT_FILE_SCHEMA , projectsExplorerProvider } from "../extension" ;
6
6
import { WorkspaceNode } from "./models/workspaceNode" ;
7
7
import { outputChannel } from "../utils" ;
8
8
import { DocumentContentProvider } from "../providers/DocumentContentProvider" ;
@@ -47,13 +47,25 @@ export function registerExplorerOpen(): vscode.Disposable {
47
47
"vscode-objectscript.explorer.open" ,
48
48
async function ( uri : vscode . Uri , project ?: string , fullName ?: string ) {
49
49
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 ;
54
52
55
53
try {
56
54
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
+ }
57
69
// This scheme is implemented by our DocumentContentProvider, which always returns text.
58
70
// If the server supplied binary data our provider substitutes a text explanation of how to work with binary content.
59
71
await vscode . window . showTextDocument ( uri , { preview : usePreview } ) ;
0 commit comments