-
Notifications
You must be signed in to change notification settings - Fork 882
Tracking PR for the remote viewer #11634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
bdcfd63
fe49bf7
c259305
e5aa4cc
d3ee53a
7133c8b
acfeb70
f24a78a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,18 @@ | |||||
| "category": "Slint", | ||||||
| "icon": "$(preview)" | ||||||
| }, | ||||||
| { | ||||||
| "command": "slint.selectRemotePreview", | ||||||
| "title": "Connect to Remote Preview", | ||||||
| "category": "Slint", | ||||||
| "icon": "$(preview)" | ||||||
| }, | ||||||
| { | ||||||
| "command": "slint.disconnectRemotePreview", | ||||||
| "title": "Disconnect Remote Preview", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "category": "Slint", | ||||||
| "icon": "$(debug-disconnect)" | ||||||
| }, | ||||||
| { | ||||||
| "command": "slint.reload", | ||||||
| "title": "Restart server", | ||||||
|
|
@@ -107,6 +119,10 @@ | |||||
| "command": "slint.showPreview", | ||||||
| "when": "editorLangId == slint" | ||||||
| }, | ||||||
| { | ||||||
| "command": "slint.selectRemotePreview", | ||||||
| "when": "editorLangId == slint" | ||||||
| }, | ||||||
| { | ||||||
| "command": "slint.reload" | ||||||
| }, | ||||||
|
|
@@ -253,4 +269,4 @@ | |||||
| "typescript": "catalog:", | ||||||
| "vscode-tmgrammar-test": "0.1.3" | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import * as vscode from "vscode"; | |
| import { SlintTelemetrySender } from "./telemetry"; | ||
| import * as common from "./common"; | ||
| import { NotificationType } from "vscode-languageclient"; | ||
| import * as lsp_commands from "./lsp_commands"; | ||
|
|
||
| import { | ||
| LanguageClient, | ||
|
|
@@ -189,6 +190,7 @@ function startClient( | |
| const devBuild = serverModule.includes("/target/debug/"); | ||
| if (devBuild) { | ||
| options.env["RUST_BACKTRACE"] = "1"; | ||
| options.env["RUST_LOG"] = "debug"; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This causes the LSP to spam a lot of things in the output panel. Not something i like a lot. |
||
| } | ||
|
|
||
| options.env["SLINT_LSP_PANIC_LOG_DIR"] = lsp_panic_log_dir(context).fsPath; | ||
|
|
@@ -234,6 +236,10 @@ function startClient( | |
| handleTelemetryEvent(params.type, context.globalState); | ||
| }, | ||
| ); | ||
|
|
||
| common.setRemoteViewerStatusBarItemState( | ||
| common.RemoteViewerStatusBarItemState.disconnected, | ||
| ); | ||
| }); | ||
|
|
||
| const cl = new LanguageClient( | ||
|
|
@@ -319,6 +325,8 @@ export function activate(context: vscode.ExtensionContext) { | |
| return; | ||
| } | ||
|
|
||
| setupRemotePreview(context); | ||
|
|
||
| const custom_lsp = !serverModule.startsWith( | ||
| path.join(context.extensionPath, "bin"), | ||
| ); | ||
|
|
@@ -406,3 +414,102 @@ function startTelemetryTimer( | |
| } | ||
| } | ||
| } | ||
|
|
||
| const remotePreviewConnectionStringMatcher = | ||
| /^(?:\[(?<ipv6>[0-9A-Fa-f:.]+)\]|(?<host>[^:\s\[\]]+)):(?<port>\d{1,5})$/; | ||
|
|
||
| function setupRemotePreview(context: vscode.ExtensionContext) { | ||
| const remoteViewerStatusBarItem = vscode.window.createStatusBarItem( | ||
| vscode.StatusBarAlignment.Right, | ||
| 100, | ||
| ); | ||
|
|
||
| common.updateRemoteViewerStatusBarItem(remoteViewerStatusBarItem); | ||
| common.setRemoteViewerStatusBarItemState( | ||
| common.RemoteViewerStatusBarItemState.disconnected, | ||
| ); | ||
| remoteViewerStatusBarItem.show(); | ||
|
|
||
| context.subscriptions.push( | ||
| vscode.commands.registerCommand("slint.selectRemotePreview", () => { | ||
| const picker = vscode.window.createQuickPick< | ||
| vscode.QuickPickItem & Partial<common.RemoteViewerInfo> | ||
| >(); | ||
| picker.title = "Select a remote preview"; | ||
| picker.placeholder = "Manual entry (e.g. 127.0.1:1234)"; | ||
| picker.ignoreFocusOut = true; | ||
|
|
||
| const updateItems = () => { | ||
| const typed = picker.value.trim(); | ||
| const items: (vscode.QuickPickItem & | ||
| Partial<common.RemoteViewerInfo>)[] = []; | ||
|
|
||
| remotePreviewConnectionStringMatcher.lastIndex = 0; | ||
| const match = remotePreviewConnectionStringMatcher.exec(typed); | ||
|
|
||
| if (match) { | ||
| items.push({ | ||
| id: "ENTER", | ||
| label: `Use typed value: ${typed}`, | ||
| detail: "", | ||
| alwaysShow: true, | ||
| value: { | ||
| addresses: [ | ||
| match.groups?.ipv6 ?? match.groups?.host ?? "", | ||
| ], | ||
| port: Number.parseInt(match.groups?.port ?? "1234"), | ||
| }, | ||
| }); | ||
| items.push({ | ||
| id: "sep", | ||
| label: "", | ||
| kind: vscode.QuickPickItemKind.Separator, | ||
| }); | ||
| } | ||
|
|
||
| items.push(...common.remote_viewers.values()); | ||
|
|
||
| picker.items = items; | ||
| }; | ||
|
|
||
| const connect = (item: common.RemoteViewerInfo) => { | ||
| lsp_commands.connectRemotePreview( | ||
| item.value.addresses, | ||
| item.value.port, | ||
| ); | ||
| common.setRemoteViewerStatusBarItemState( | ||
| common.RemoteViewerStatusBarItemState.connecting, | ||
| ); | ||
|
|
||
| picker.hide(); | ||
| }; | ||
|
|
||
| // picker.onDidAccept(() => { | ||
| // const picked = picker.activeItems[0] ?? picker.selectedItems[0]; | ||
| // if (picked) { | ||
| // connect(picked as common.RemoteViewerInfo); | ||
| // } | ||
| // }); | ||
|
|
||
| picker.onDidChangeSelection((items) => { | ||
| const picked = items[0]; | ||
| if (picked) { | ||
| connect(picked as common.RemoteViewerInfo); | ||
| } | ||
| }); | ||
|
|
||
| picker.onDidHide(() => { | ||
| picker.dispose(); | ||
| }); | ||
|
|
||
| updateItems(); | ||
| picker.onDidChangeValue(updateItems); | ||
|
|
||
| picker.show(); | ||
| }), | ||
| remoteViewerStatusBarItem, | ||
| vscode.commands.registerCommand("slint.disconnectRemotePreview", () => { | ||
| lsp_commands.disconnectRemotePreview(); | ||
| }), | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,16 @@ | ||
| { | ||
| "extends": "../tsconfig.default.json", | ||
| "compilerOptions": { | ||
| "lib": ["es2021", "webworker"], | ||
| "types": ["vscode"] | ||
| "target": "ES2021", | ||
| "lib": [ | ||
| "es2021", | ||
| "webworker" | ||
| ], | ||
| "types": [ | ||
| "vscode" | ||
| ] | ||
| }, | ||
| "include": ["./*.ts", "./*.d.ts"] | ||
| } | ||
| "include": [ | ||
| "./*.ts" | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.