Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
haouarihk committed Mar 18, 2024
1 parent 138a2b4 commit 68a8611
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/scope/context-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class ContextManager {

const contextTemplate = this.plugin.settings.context.customInstructEnabled
? this.plugin.settings.context.customInstruct ||
this.plugin.defaultSettings.context.customInstruct
this.plugin.defaultSettings.context.customInstruct
: "{{tg_selection}}";

const options = await this.getDefaultContext(
Expand Down Expand Up @@ -385,7 +385,7 @@ export default class ContextManager {
keys?: ReturnType<InstanceType<typeof TextGeneratorPlugin>["getApiKeys"]>;
_variables: Record<string, true>;
} = {
_variables: {},
_variables: {}
};

const vars =
Expand All @@ -395,9 +395,9 @@ export default class ContextManager {
const title =
vars["title"] || vars["mentions"]
? (filePath
? this.app.vault.getAbstractFileByPath(filePath)?.name ||
this.getActiveFileTitle()
: this.getActiveFileTitle()) || ""
? this.app.vault.getAbstractFileByPath(filePath)?.name ||
this.getActiveFileTitle()
: this.getActiveFileTitle()) || ""
: "";

const activeDocCache = this.getMetaData(filePath || "");
Expand Down Expand Up @@ -526,18 +526,18 @@ export default class ContextManager {

const preRunnerTemplate = preRunnerContent
? this.handlebarsMiddleware(
Handlebars.compile(preRunnerContent, {
noEscape: true,
})
)
Handlebars.compile(preRunnerContent, {
noEscape: true,
})
)
: null;

const outputTemplate = outputContent
? this.handlebarsMiddleware(
Handlebars.compile(outputContent, {
noEscape: true,
})
)
Handlebars.compile(outputContent, {
noEscape: true,
})
)
: null;

return {
Expand Down Expand Up @@ -847,13 +847,13 @@ export default class ContextManager {
const extractorMethods = getExtractorMethods().filter(
(e) =>
this.plugin.settings.extractorsOptions[
e as keyof typeof this.plugin.settings.extractorsOptions
e as keyof typeof this.plugin.settings.extractorsOptions
]
);

const targetFile = filePath
? app.vault.getAbstractFileByPath(filePath) ||
this.app.workspace.getActiveFile()
this.app.workspace.getActiveFile()
: this.app.workspace.getActiveFile();

const targetFileContent = editor
Expand Down Expand Up @@ -1372,4 +1372,9 @@ Or
example: `{{error "Selection was empty"}}`,
hint: "Shows a error notice to the user, and it will stop the execution.",
},

keys: {
example: `{{keys.openAIChat}}`,
hint: "Gives access to generic provider's api keys",
},
};

0 comments on commit 68a8611

Please sign in to comment.