Skip to content

Commit

Permalink
added more notifications in the editor when loading a file
Browse files Browse the repository at this point in the history
  • Loading branch information
atiderko committed Oct 9, 2024
1 parent f98fc48 commit 1c24f9d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ function FileEditorPanel({ tabId, providerId, rootFilePath, currentFilePath, fil
async (uriPath, range = null, launchArgs = null, forceReload = false) => {
if (!uriPath) return false;
setCurrentFile({ name: getFileName(uriPath), requesting: true });
setNotificationDescription("Getting file from provider...");
// If model does not exist, try to fetch it
let result = await monacoCtx.getModel(tabId, providerId, uriPath, forceReload);
setCurrentFile({ name: getFileName(uriPath), requesting: false });
setNotificationDescription("");

// get model from path if exists
if (!result.model) {
Expand Down Expand Up @@ -325,8 +327,10 @@ function FileEditorPanel({ tabId, providerId, rootFilePath, currentFilePath, fil
// unset modified flag of the current model
setActiveModel(async (prevModel) => {
setCurrentFile({ name: getFileName(prevModel.path), requesting: true });
setNotificationDescription("Getting file from provider...");
const result = await monacoCtx.getModel(tabId, providerId, prevModel.path, false);
setCurrentFile({ name: getFileName(prevModel.path), requesting: false });
setNotificationDescription("");
result.model.modified = false;
const id = `editor-${providerObj.connection.host}-${providerObj.connection.port}-${rootFilePath}`;
window.editorManager?.changed(id, path, false);
Expand Down Expand Up @@ -395,8 +399,10 @@ function FileEditorPanel({ tabId, providerId, rootFilePath, currentFilePath, fil
if (activeModel) {
if (!activeModel.modified) {
setCurrentFile({ name: getFileName(activeModel.path), requesting: true });
setNotificationDescription("Getting file from provider...");
const result = await monacoCtx.getModel(tabId, providerId, activeModel.path, false);
setCurrentFile({ name: getFileName(activeModel.path), requesting: false });
setNotificationDescription("");
result.model.modified = true;
setActiveModel({ path: result.model.uri.path, modified: result.model.modified, model: result.model });
updateModifiedFiles();
Expand Down Expand Up @@ -953,7 +959,7 @@ function FileEditorPanel({ tabId, providerId, rootFilePath, currentFilePath, fil
<UpgradeIcon style={{ fontSize: "0.8em" }} />
</IconButton>
</Tooltip>
<Tooltip title="Reload current file from host" disableInteractive>
<Tooltip title="Drop unsaved changes and reload current file from host" disableInteractive>
<IconButton
edge="end"
aria-label="Reload file"
Expand Down Expand Up @@ -1035,7 +1041,6 @@ function FileEditorPanel({ tabId, providerId, rootFilePath, currentFilePath, fil
{notificationDescription}
</Alert>
)}
{/* {activeModel && ( */}
<Monaco.Editor
key="editor"
height={editorHeight}
Expand Down Expand Up @@ -1067,7 +1072,6 @@ function FileEditorPanel({ tabId, providerId, rootFilePath, currentFilePath, fil
},
}}
/>
{/* // )} */}
</Stack>
</SplitPane>
</Stack>
Expand Down

0 comments on commit 1c24f9d

Please sign in to comment.