mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
Ignore workspace settings for untrusted folders (#6606)
This commit is contained in:
parent
179f1414da
commit
d250293c2e
16 changed files with 386 additions and 122 deletions
|
|
@ -4,14 +4,15 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { useState, useCallback } from 'react';
|
||||
import { LoadedSettings, SettingScope } from '../../config/settings.js';
|
||||
import { useState, useCallback, useContext } from 'react';
|
||||
import { SettingScope } from '../../config/settings.js';
|
||||
import { type HistoryItem, MessageType } from '../types.js';
|
||||
import {
|
||||
allowEditorTypeInSandbox,
|
||||
checkHasEditorType,
|
||||
EditorType,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { SettingsContext } from '../contexts/SettingsContext.js';
|
||||
|
||||
interface UseEditorSettingsReturn {
|
||||
isEditorDialogOpen: boolean;
|
||||
|
|
@ -24,11 +25,11 @@ interface UseEditorSettingsReturn {
|
|||
}
|
||||
|
||||
export const useEditorSettings = (
|
||||
loadedSettings: LoadedSettings,
|
||||
setEditorError: (error: string | null) => void,
|
||||
addItem: (item: Omit<HistoryItem, 'id'>, timestamp: number) => void,
|
||||
): UseEditorSettingsReturn => {
|
||||
const [isEditorDialogOpen, setIsEditorDialogOpen] = useState(false);
|
||||
const settingsContext = useContext(SettingsContext);
|
||||
|
||||
const openEditorDialog = useCallback(() => {
|
||||
setIsEditorDialogOpen(true);
|
||||
|
|
@ -45,7 +46,11 @@ export const useEditorSettings = (
|
|||
}
|
||||
|
||||
try {
|
||||
loadedSettings.setValue(scope, 'preferredEditor', editorType);
|
||||
settingsContext?.settings.setValue(
|
||||
scope,
|
||||
'preferredEditor',
|
||||
editorType,
|
||||
);
|
||||
addItem(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
|
|
@ -59,7 +64,7 @@ export const useEditorSettings = (
|
|||
setEditorError(`Failed to set editor preference: ${error}`);
|
||||
}
|
||||
},
|
||||
[loadedSettings, setEditorError, addItem],
|
||||
[settingsContext, setEditorError, addItem],
|
||||
);
|
||||
|
||||
const exitEditorDialog = useCallback(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue