-
Notifications
You must be signed in to change notification settings - Fork 666
Provide several hints for better user experience #293
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0fc7394
Provide several hints for better user experience
Vigilans 51b6464
Merge branch 'master' into vigilans/hint
Vigilans 8e2f691
Wrap open settings & keybindings function
Vigilans fc95c8c
Resolve comments in review
Vigilans bba3239
Merge branch 'vigilans/hint' of github.com:jdneo/vscode-leetcode into…
Vigilans 4b783ac
Merge branch 'master' into vigilans/hint
jdneo 77c7140
Address comments in review
Vigilans ce1c238
Merge branch 'vigilans/hint' of github.com:jdneo/vscode-leetcode into…
Vigilans ca9a209
Merge branch 'master' into vigilans/hint
jdneo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import * as vscode from "vscode"; | ||
import { getLeetCodeEndpoint } from "../commands/plugin"; | ||
import { leetCodeChannel } from "../leetCodeChannel"; | ||
import { getWorkspaceConfiguration } from "./workspaceUtils"; | ||
|
||
export namespace DialogOptions { | ||
export const open: vscode.MessageItem = { title: "Open" }; | ||
|
@@ -57,6 +58,29 @@ export async function promptForSignIn(): Promise<void> { | |
} | ||
} | ||
|
||
export async function promptHintMessage(config: string, message: string, choiceConfirm: string, onConfirm: () => Promise<any>): Promise<void> { | ||
if (getWorkspaceConfiguration().get<boolean>(`${config}`)) { | ||
const choiceNoShowAgain: string = "Don't show again"; | ||
const choice: string | undefined = await vscode.window.showInformationMessage( | ||
message, choiceConfirm, choiceNoShowAgain, | ||
); | ||
if (choice === choiceConfirm) { | ||
await onConfirm(); | ||
} else if (choice === choiceNoShowAgain) { | ||
await getWorkspaceConfiguration().update(`${config}`, false, true /* UserSetting */); | ||
} | ||
} | ||
} | ||
|
||
export async function openSettingsEditor(query?: string): Promise<void> { | ||
await vscode.commands.executeCommand("workbench.action.openSettings", query); | ||
} | ||
|
||
export async function openKeybindingsEditor(query?: string): Promise<void> { | ||
await vscode.commands.executeCommand("workbench.action.openGlobalKeybindings", query); | ||
} | ||
|
||
|
||
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. nit: multiple empty line |
||
export async function showFileSelectDialog(): Promise<vscode.Uri[] | undefined> { | ||
const defaultUri: vscode.Uri | undefined = vscode.workspace.rootPath ? vscode.Uri.file(vscode.workspace.rootPath) : undefined; | ||
const options: vscode.OpenDialogOptions = { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// Licensed under the MIT license. | ||
|
||
import { ViewColumn } from "vscode"; | ||
import { openKeybindingsEditor, promptHintMessage } from "../utils/uiUtils"; | ||
import { ILeetCodeWebviewOption, LeetCodeWebview } from "./LeetCodeWebview"; | ||
import { markdownEngine } from "./markdownEngine"; | ||
|
||
|
@@ -13,6 +14,7 @@ class LeetCodeSubmissionProvider extends LeetCodeWebview { | |
public show(result: string): void { | ||
this.result = result; | ||
this.showWebviewInternal(); | ||
this.showKeybindingsHint(); | ||
} | ||
|
||
protected getWebviewOption(): ILeetCodeWebviewOption { | ||
|
@@ -40,6 +42,15 @@ class LeetCodeSubmissionProvider extends LeetCodeWebview { | |
super.onDidDisposeWebview(); | ||
delete this.result; | ||
} | ||
|
||
private async showKeybindingsHint(): Promise<void> { | ||
await promptHintMessage( | ||
"hint.commandShortcut", | ||
'You can configure custom key bindings with "test", "submit" or any other command in Preferences > Keyboard Shortcuts.', | ||
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. You can customize the shortcut key bindings in Preferences > Keyboard Shortcuts. |
||
"Open Keybindings", | ||
(): Promise<any> => openKeybindingsEditor("leetcode solution"), | ||
); | ||
} | ||
} | ||
|
||
export const leetCodeSubmissionProvider: LeetCodeSubmissionProvider = new LeetCodeSubmissionProvider(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You can generate the code file with problem description in the comments by .....