Skip to content

Commit dfe5fd5

Browse files
committed
Fix scrolling in editor
1 parent 3a86247 commit dfe5fd5

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-17
lines changed

src/activate/registerCommands.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,11 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
8989
}
9090

9191
const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
92-
outputChannel.appendLine("Opening Roo Code in new tab")
93-
9492
// (This example uses webviewProvider activation event which is necessary to
9593
// deserialize cached webview, but since we use retainContextWhenHidden, we
9694
// don't need to use that event).
9795
// https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
98-
const tabProvider = new ClineProvider(context, outputChannel)
99-
// const column = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.viewColumn : undefined
96+
const tabProvider = new ClineProvider(context, outputChannel, "editor")
10097
const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0))
10198

10299
// Check if there are any visible text editors, otherwise open a new group
@@ -115,10 +112,10 @@ const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterComman
115112
localResourceRoots: [context.extensionUri],
116113
})
117114

118-
// Save as tab type panel
115+
// Save as tab type panel.
119116
setPanel(newPanel, "tab")
120117

121-
// TODO: use better svg icon with light and dark variants (see
118+
// TODO: Use better svg icon with light and dark variants (see
122119
// https://stackoverflow.com/questions/58365687/vscode-extension-iconpath).
123120
newPanel.iconPath = {
124121
light: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "rocket.png"),
@@ -127,12 +124,12 @@ const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterComman
127124

128125
await tabProvider.resolveWebviewView(newPanel)
129126

130-
// Handle panel closing events
127+
// Handle panel closing events.
131128
newPanel.onDidDispose(() => {
132129
setPanel(undefined, "tab")
133130
})
134131

135-
// Lock the editor group so clicking on files doesn't open them over the panel
132+
// Lock the editor group so clicking on files doesn't open them over the panel.
136133
await delay(100)
137134
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
138135
}

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
9191
constructor(
9292
readonly context: vscode.ExtensionContext,
9393
private readonly outputChannel: vscode.OutputChannel,
94+
private readonly renderContext: "sidebar" | "editor" = "sidebar",
9495
) {
9596
super()
9697

@@ -2375,11 +2376,10 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
23752376
showRooIgnoredFiles,
23762377
language,
23772378
} = await this.getState()
2379+
23782380
const telemetryKey = process.env.POSTHOG_API_KEY
23792381
const machineId = vscode.env.machineId
2380-
23812382
const allowedCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("allowedCommands") || []
2382-
23832383
const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) || ""
23842384

23852385
return {
@@ -2441,6 +2441,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
24412441
machineId,
24422442
showRooIgnoredFiles: showRooIgnoredFiles ?? true,
24432443
language,
2444+
renderContext: this.renderContext,
24442445
}
24452446
}
24462447

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function activate(context: vscode.ExtensionContext) {
5656
context.globalState.update("allowedCommands", defaultCommands)
5757
}
5858

59-
const provider = new ClineProvider(context, outputChannel)
59+
const provider = new ClineProvider(context, outputChannel, "sidebar")
6060
telemetryService.setProvider(provider)
6161

6262
// Validate task history on extension activation

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export interface ExtensionState {
154154
telemetryKey?: string
155155
machineId?: string
156156
showRooIgnoredFiles: boolean // Whether to show .rooignore'd files in listings
157+
renderContext: "sidebar" | "editor"
157158
}
158159

159160
export type { ClineMessage, ClineAsk, ClineSay }

webview-ui/src/components/common/Tab.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { HTMLAttributes } from "react"
1+
import { HTMLAttributes, useCallback } from "react"
22

3+
import { useExtensionState } from "@/context/ExtensionStateContext"
34
import { cn } from "@/lib/utils"
45

56
type TabProps = HTMLAttributes<HTMLDivElement>
@@ -16,8 +17,31 @@ export const TabHeader = ({ className, children, ...props }: TabProps) => (
1617
</div>
1718
)
1819

19-
export const TabContent = ({ className, children, ...props }: TabProps) => (
20-
<div className={cn("flex-1 overflow-auto p-5", className)} {...props}>
21-
{children}
22-
</div>
23-
)
20+
export const TabContent = ({ className, children, ...props }: TabProps) => {
21+
const { renderContext } = useExtensionState()
22+
23+
const onWheel = useCallback(
24+
(e: React.WheelEvent<HTMLDivElement>) => {
25+
if (renderContext !== "editor") {
26+
return
27+
}
28+
29+
const target = e.target as HTMLElement
30+
31+
// Prevent scrolling if the target is a listbox or option
32+
// (e.g. selects, dropdowns, etc).
33+
if (target.role === "listbox" || target.role === "option") {
34+
return
35+
}
36+
37+
e.currentTarget.scrollTop += e.deltaY
38+
},
39+
[renderContext],
40+
)
41+
42+
return (
43+
<div className={cn("flex-1 overflow-auto p-5", className)} onWheel={onWheel} {...props}>
44+
{children}
45+
</div>
46+
)
47+
}

webview-ui/src/components/prompts/PromptsView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function getGroupName(group: GroupEntry): ToolGroup {
4545

4646
const PromptsView = ({ onDone }: PromptsViewProps) => {
4747
const { t } = useAppTranslation()
48+
4849
const {
4950
customModePrompts,
5051
customSupportPrompts,

0 commit comments

Comments
 (0)