Просмотр исходного кода

Removed active selection for now

Matt Rubens 11 месяцев назад
Родитель
Сommit
1e5a257e52

+ 0 - 30
src/integrations/workspace/WorkspaceTracker.ts

@@ -50,22 +50,7 @@ class WorkspaceTracker {
 
 		this.disposables.push(watcher)
 
-		// Listen for tab changes
 		this.disposables.push(vscode.window.tabGroups.onDidChangeTabs(() => this.workspaceDidUpdate()))
-
-		// Listen for editor/selection changes
-		this.disposables.push(vscode.window.onDidChangeActiveTextEditor(() => this.workspaceDidUpdate()))
-		this.disposables.push(vscode.window.onDidChangeTextEditorSelection(() => this.workspaceDidUpdate()))
-
-		/*
-		 An event that is emitted when a workspace folder is added or removed.
-		 **Note:** this event will not fire if the first workspace folder is added, removed or changed,
-		 because in that case the currently executing extensions (including the one that listens to this
-		 event) will be terminated and restarted so that the (deprecated) `rootPath` property is updated
-		 to point to the first workspace folder.
-		 */
-		// In other words, we don't have to worry about the root workspace folder ([0]) changing since the extension will be restarted and our cwd will be updated to reflect the new workspace folder. (We don't care about non root workspace folders, since cline will only be working within the root folder cwd)
-		// this.disposables.push(vscode.workspace.onDidChangeWorkspaceFolders(this.onWorkspaceFoldersChanged.bind(this)))
 	}
 
 	private getOpenedTabsInfo() {
@@ -83,20 +68,6 @@ class WorkspaceTracker {
 		)
 	}
 
-	private getActiveSelectionInfo() {
-		const editor = vscode.window.activeTextEditor
-		if (!editor) return null
-		if (editor.selection.isEmpty) return null
-
-		return {
-			file: toRelativePath(editor.document.uri.fsPath, cwd || ""),
-			selection: {
-				startLine: editor.selection.start.line,
-				endLine: editor.selection.end.line,
-			},
-		}
-	}
-
 	private workspaceDidUpdate() {
 		if (this.updateTimer) {
 			clearTimeout(this.updateTimer)
@@ -112,7 +83,6 @@ class WorkspaceTracker {
 				type: "workspaceUpdated",
 				filePaths: relativeFilePaths,
 				openedTabs: this.getOpenedTabsInfo(),
-				activeSelection: this.getActiveSelectionInfo(),
 			})
 			this.updateTimer = null
 		}, 300) // Debounce for 300ms

+ 0 - 7
src/shared/ExtensionMessage.ts

@@ -62,13 +62,6 @@ export interface ExtensionMessage {
 		isActive: boolean
 		path?: string
 	}>
-	activeSelection?: {
-		file: string
-		selection: {
-			startLine: number
-			endLine: number
-		}
-	} | null
 	partialMessage?: ClineMessage
 	glamaModels?: Record<string, ModelInfo>
 	openRouterModels?: Record<string, ModelInfo>

+ 2 - 10
webview-ui/src/components/chat/ChatTextArea.tsx

@@ -50,8 +50,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
 		},
 		ref,
 	) => {
-		const { filePaths, openedTabs, activeSelection, currentApiConfigName, listApiConfigMeta, customModes } =
-			useExtensionState()
+		const { filePaths, openedTabs, currentApiConfigName, listApiConfigMeta, customModes } = useExtensionState()
 		const [gitCommits, setGitCommits] = useState<any[]>([])
 		const [showDropdown, setShowDropdown] = useState(false)
 
@@ -158,15 +157,8 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
 					})),
 			]
 
-			if (activeSelection) {
-				items.unshift({
-					type: ContextMenuOptionType.OpenedFile,
-					value: `/${activeSelection.file}:${activeSelection.selection.startLine + 1}-${activeSelection.selection.endLine + 1}`,
-				})
-			}
-
 			return items
-		}, [filePaths, openedTabs, activeSelection])
+		}, [filePaths, openedTabs])
 
 		useEffect(() => {
 			const handleClickOutside = (event: MouseEvent) => {

+ 0 - 11
webview-ui/src/context/ExtensionStateContext.tsx

@@ -28,10 +28,6 @@ export interface ExtensionStateContextType extends ExtensionState {
 	mcpServers: McpServer[]
 	filePaths: string[]
 	openedTabs: Array<{ label: string; isActive: boolean; path?: string }>
-	activeSelection: {
-		file: string
-		selection: { startLine: number; endLine: number }
-	} | null
 	setApiConfiguration: (config: ApiConfiguration) => void
 	setCustomInstructions: (value?: string) => void
 	setAlwaysAllowReadOnly: (value: boolean) => void
@@ -122,10 +118,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
 		[glamaDefaultModelId]: glamaDefaultModelInfo,
 	})
 	const [openedTabs, setOpenedTabs] = useState<Array<{ label: string; isActive: boolean; path?: string }>>([])
-	const [activeSelection, setActiveSelection] = useState<{
-		file: string
-		selection: { startLine: number; endLine: number }
-	} | null>(null)
 	const [openRouterModels, setOpenRouterModels] = useState<Record<string, ModelInfo>>({
 		[openRouterDefaultModelId]: openRouterDefaultModelInfo,
 	})
@@ -188,11 +180,9 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
 				case "workspaceUpdated": {
 					const paths = message.filePaths ?? []
 					const tabs = message.openedTabs ?? []
-					const selection = message.activeSelection ?? null
 
 					setFilePaths(paths)
 					setOpenedTabs(tabs)
-					setActiveSelection(selection)
 					break
 				}
 				case "partialMessage": {
@@ -260,7 +250,6 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
 		mcpServers,
 		filePaths,
 		openedTabs,
-		activeSelection,
 		soundVolume: state.soundVolume,
 		fuzzyMatchThreshold: state.fuzzyMatchThreshold,
 		writeDelayMs: state.writeDelayMs,