💄 inline keyboard shortcut suggestions
This commit is contained in:
parent
2da609afcd
commit
ef1433a7b7
6 changed files with 55 additions and 9 deletions
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"API_URL": "http://localhost:65432"
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"API_URL": "http://localhost:65432"
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"API_URL": "https://basin.dev"
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import { registerAllCommands } from "../commands";
|
|||
import registerQuickFixProvider from "../lang-server/codeActions";
|
||||
import { getExtensionUri } from "../util/vscode";
|
||||
import path from "path";
|
||||
import { setupInlineTips } from "./inlineTips";
|
||||
|
||||
export let extensionContext: vscode.ExtensionContext | undefined = undefined;
|
||||
|
||||
|
|
@ -87,6 +88,7 @@ export async function activateExtension(context: vscode.ExtensionContext) {
|
|||
registerQuickFixProvider();
|
||||
addPythonPathForConfig();
|
||||
await openTutorial(context);
|
||||
setupInlineTips(context);
|
||||
|
||||
// Start the server
|
||||
const sessionIdPromise = (async () => {
|
||||
|
|
|
|||
48
extensions/vscode/src/activation/inlineTips.ts
Normal file
48
extensions/vscode/src/activation/inlineTips.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import * as vscode from "vscode";
|
||||
|
||||
const inlineTipDecoration = vscode.window.createTextEditorDecorationType({
|
||||
after: {
|
||||
contentText: "⌘ M to select code, ⌘ ⇧ M to edit",
|
||||
color: "#d3d3d340",
|
||||
margin: "0 0 0 6em",
|
||||
},
|
||||
});
|
||||
|
||||
function handleSelectionChange(e: vscode.TextEditorSelectionChangeEvent) {
|
||||
const selection = e.selections[0];
|
||||
const editor = e.textEditor;
|
||||
if (
|
||||
selection.isEmpty ||
|
||||
vscode.workspace
|
||||
.getConfiguration("continue")
|
||||
.get<boolean>("showInlineTip") === false
|
||||
) {
|
||||
editor.setDecorations(inlineTipDecoration, []);
|
||||
return;
|
||||
}
|
||||
|
||||
const startLine = selection.start.line;
|
||||
|
||||
let lineToShow = startLine > 0 ? startLine - 1 : startLine + 1;
|
||||
|
||||
const hoverMarkdown = new vscode.MarkdownString(
|
||||
"Use ⌘ M to select code, or ⌘ ⇧ M to select code and use the /edit slash command. Click [here](command:continue.hideInlineTip) if you don't want to see these inline suggestions."
|
||||
);
|
||||
hoverMarkdown.isTrusted = true;
|
||||
hoverMarkdown.supportHtml = true;
|
||||
editor.setDecorations(inlineTipDecoration, [
|
||||
{
|
||||
range: new vscode.Range(
|
||||
new vscode.Position(lineToShow, Number.MAX_VALUE),
|
||||
new vscode.Position(lineToShow, Number.MAX_VALUE)
|
||||
),
|
||||
hoverMessage: [hoverMarkdown],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
export function setupInlineTips(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(
|
||||
vscode.window.onDidChangeTextEditorSelection(handleSelectionChange)
|
||||
);
|
||||
}
|
||||
|
|
@ -104,6 +104,11 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
|
|||
vscode.commands.executeCommand("continue.continueGUIView.focus");
|
||||
await ideProtocolClient.debugTerminal();
|
||||
},
|
||||
"continue.hideInlineTip": () => {
|
||||
vscode.workspace
|
||||
.getConfiguration("continue")
|
||||
.update("showInlineTip", false);
|
||||
},
|
||||
|
||||
// Commands without keyboard shortcuts
|
||||
"continue.addModel": () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue