feat(editor): seed Find from selected text (#9982)
This commit is contained in:
parent
d6c9fcd537
commit
034aeb15e4
|
|
@ -10,6 +10,7 @@ import type { DiffSection } from './diff-section-types'
|
|||
import { translate } from '@/i18n/i18n'
|
||||
import { LargeDiffFallback } from './LargeDiffFallback'
|
||||
import { buildDiffEditorWordWrapOptions } from './diff-editor-word-wrap-options'
|
||||
import { monacoFindOptions } from './monaco-find-options'
|
||||
|
||||
const ImageDiffViewer = lazy(() => import('./ImageDiffViewer'))
|
||||
|
||||
|
|
@ -198,11 +199,7 @@ export function DiffSectionBody({
|
|||
renderOverviewRuler: false,
|
||||
scrollbar: combinedDiffSectionScrollbarOptions,
|
||||
hideUnchangedRegions: { enabled: true },
|
||||
find: {
|
||||
addExtraSpaceOnTop: false,
|
||||
autoFindInSelection: 'never',
|
||||
seedSearchStringFromSelection: 'never'
|
||||
}
|
||||
find: monacoFindOptions
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import type { DiffViewerProps } from './diff-viewer-props'
|
|||
import { buildDiffEditorWordWrapOptions } from './diff-editor-word-wrap-options'
|
||||
import { useDiffEditorRegistration } from './diff-navigation-context'
|
||||
import { preserveDiffViewStateAcrossModelSwaps } from './diff-model-swap-view-state'
|
||||
import { monacoFindOptions } from './monaco-find-options'
|
||||
|
||||
export default function DiffViewer({
|
||||
modelKey,
|
||||
|
|
@ -429,11 +430,7 @@ export default function DiffViewer({
|
|||
renderOverviewRuler: true,
|
||||
scrollbar: diffEditorScrollbarOptions,
|
||||
padding: { top: 0 },
|
||||
find: {
|
||||
addExtraSpaceOnTop: false,
|
||||
autoFindInSelection: 'never',
|
||||
seedSearchStringFromSelection: 'never'
|
||||
}
|
||||
find: monacoFindOptions
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ import {
|
|||
isMonacoAutoHeightCapped
|
||||
} from './monaco-auto-height'
|
||||
import { installMonacoE2EProbe } from './monaco-e2e-probe'
|
||||
import { monacoFindOptions } from './monaco-find-options'
|
||||
|
||||
type MonacoEditorProps = {
|
||||
fileId: string
|
||||
|
|
@ -848,11 +849,7 @@ export default function MonacoEditor({
|
|||
smoothScrolling: true,
|
||||
cursorSmoothCaretAnimation: 'off',
|
||||
padding: { top: 0 },
|
||||
find: {
|
||||
addExtraSpaceOnTop: false,
|
||||
autoFindInSelection: 'never',
|
||||
seedSearchStringFromSelection: 'never'
|
||||
},
|
||||
find: monacoFindOptions,
|
||||
// Why: Monaco owns its rendered line surface, so align its selection-clipboard with the app opt-out (the global DOM hook can't).
|
||||
selectionClipboard: settings?.primarySelectionMiddleClickPaste ?? isLinuxUserAgent()
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
import { monacoFindOptions } from './monaco-find-options'
|
||||
|
||||
describe('monacoFindOptions', () => {
|
||||
it('seeds Find only from an explicit selection without changing its layout or scope', () => {
|
||||
expect(monacoFindOptions).toEqual({
|
||||
addExtraSpaceOnTop: false,
|
||||
autoFindInSelection: 'never',
|
||||
seedSearchStringFromSelection: 'selection'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import type { editor } from 'monaco-editor'
|
||||
|
||||
export const monacoFindOptions = {
|
||||
addExtraSpaceOnTop: false,
|
||||
autoFindInSelection: 'never',
|
||||
seedSearchStringFromSelection: 'selection'
|
||||
} satisfies editor.IEditorFindOptions
|
||||
Loading…
Reference in New Issue