diff --git a/README.md b/README.md index 623e95f..504e8e7 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround wh | `leetcode.enableStatusBar` | Specify whether the LeetCode status bar will be shown or not. | `true` | | `leetcode.editor.shortcuts` | Specify the customized shortcuts in editors. Supported values are: `submit`, `test`, `star`, `solution` and `description`. | `["submit, test"]` | | `leetcode.enableSideMode` | Specify whether `preview`, `solution` and `submission` tab should be grouped into the second editor column when solving a problem. | `true` | +| `leetcode.editorSideBySideSplit` | Specify the split layout when opening a problem file. Supported values are: `problem-left` or `problem-right` (preview on the left, problem file on the right). | `problem-left` | | `leetcode.nodePath` | Specify the `Node.js` executable path. for example, C:\Program Files\nodejs\node.exe | `node` | | `leetcode.showCommentDescription` | Specify whether to include the problem description in the comments | `false` | | `leetcode.useEndpointTranslation` | Use endpoint's translation (if available) | `true` | diff --git a/package.json b/package.json index 53552b7..c43bdf9 100644 --- a/package.json +++ b/package.json @@ -677,6 +677,20 @@ "scope": "application", "description": "Determine whether to group all webview pages into the second editor column when solving problems." }, + "leetcode.editorSideBySideSplit": { + "type": "string", + "default": "problem-left", + "scope": "application", + "enum": [ + "problem-left", + "problem-right" + ], + "enumDescriptions": [ + "Problem file on the left, preview on the right", + "Preview on the left, problem file on the right" + ], + "description": "Determine the side-by-side split layout when opening a problem file." + }, "leetcode.nodePath": { "type": "string", "default": "node", diff --git a/src/commands/show.ts b/src/commands/show.ts index eccf557..2ac9082 100644 --- a/src/commands/show.ts +++ b/src/commands/show.ts @@ -189,12 +189,14 @@ async function showProblemInternal(node: IProblem): Promise { const descriptionConfig: IDescriptionConfiguration = settingUtils.getDescriptionConfiguration(); const needTranslation: boolean = settingUtils.shouldUseEndpointTranslation(); + const editorSplit: string = leetCodeConfig.get("editorSideBySideSplit", "problem-left"); + const problemViewColumn = editorSplit === "problem-left" ? vscode.ViewColumn.One : vscode.ViewColumn.Two; await leetCodeExecutor.showProblem(node, language, finalPath, descriptionConfig.showInComment, needTranslation); const promises: any[] = [ vscode.window.showTextDocument(vscode.Uri.file(finalPath), { preview: false, - viewColumn: vscode.ViewColumn.One, + viewColumn: problemViewColumn, }), promptHintMessage( "hint.commentDescription", diff --git a/src/webview/leetCodePreviewProvider.ts b/src/webview/leetCodePreviewProvider.ts index 86060de..7b4741c 100644 --- a/src/webview/leetCodePreviewProvider.ts +++ b/src/webview/leetCodePreviewProvider.ts @@ -1,7 +1,7 @@ // Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. -import { commands, ViewColumn } from "vscode"; +import { commands, ViewColumn, workspace } from "vscode"; import { getLeetCodeEndpoint } from "../commands/plugin"; import { Endpoint, IProblem } from "../shared"; import { ILeetCodeWebviewOption, LeetCodeWebview } from "./LeetCodeWebview"; @@ -31,9 +31,12 @@ class LeetCodePreviewProvider extends LeetCodeWebview { viewColumn: ViewColumn.One, }; } else { + const editorSplit: string = workspace.getConfiguration("leetcode").get("editorSideBySideSplit", "problem-left"); + const previewViewColumn = editorSplit === "problem-left" ? ViewColumn.Two : ViewColumn.One; + return { title: "Description", - viewColumn: ViewColumn.Two, + viewColumn: previewViewColumn, preserveFocus: true, }; }