Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib/editorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,7 @@ async function EditorManager($header, $body) {
editor,
readOnlyCompartment,
getFile,
reapplyActiveFile,
switchFile,
moveFileByPinnedState,
normalizePinnedTabOrder,
Expand Down Expand Up @@ -2944,6 +2945,12 @@ async function EditorManager($header, $body) {
toggleProblemButton();
}

function reapplyActiveFile() {
const file = manager.activeFile;
if (!file || file.type !== "editor" || !file.loaded || file.loading) return;
applyFileToEditor(file, { forceRecreate: true });
}

/**
* Initializes the file tab container.
*/
Expand Down
14 changes: 9 additions & 5 deletions src/lib/languageModeRecommendations.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getModeForPath } from "cm/modelist";
import notificationManager from "lib/notificationManager";
import Path from "utils/Path";
import Url from "utils/Url";
Expand Down Expand Up @@ -98,9 +99,9 @@ class LanguageModeRecommendations {
}

this.pendingKeywords.add(keyword);
void this.showRecommendation(keyword)
.then(() => {
this.notifiedKeywords.add(keyword);
void this.showRecommendation(keyword, filename)
.then((shown) => {
if (shown) this.notifiedKeywords.add(keyword);
})
.catch((error) => {
console.warn("Failed to show extension recommendation.", error);
Expand All @@ -110,8 +111,10 @@ class LanguageModeRecommendations {
});
}

async showRecommendation(keyword) {
async showRecommendation(keyword, filename) {
const hasPlugins = await this.getPluginAvailability(keyword);
if (!hasPlainTextFallback(getModeForPath(filename), filename)) return false;

const displayExt = `.${keyword}`;

if (hasPlugins) {
Expand All @@ -135,7 +138,7 @@ class LanguageModeRecommendations {
},
],
});
return;
return true;
}

const issueUrl = getIssueUrl(keyword);
Expand All @@ -159,6 +162,7 @@ class LanguageModeRecommendations {
},
],
});
return true;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ async function onDeviceReady() {

// Re-emit events for active file after plugins are loaded
const { activeFile } = editorManager;
for (const file of editorManager.files) {
if (file?.type === "editor") {
file.setMode();
}
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
editorManager.reapplyActiveFile();
if (activeFile?.uri) {
// Re-emit file-loaded event
editorManager.emit("file-loaded", activeFile);
Expand Down