Add primary selection middle-click paste

Closes #1898
This commit is contained in:
Neil
2026-05-15 22:49:41 -07:00
committed by GitHub
parent 2ead67c650
commit e7eb42659c
27 changed files with 1192 additions and 53 deletions
+12 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { getDefaultSettings } from './constants'
import { getDefaultPrimarySelectionMiddleClickPaste, getDefaultSettings } from './constants'
describe('getDefaultSettings', () => {
it('enables gitignored file decorations by default', () => {
@@ -18,3 +18,14 @@ describe('getDefaultSettings', () => {
})
})
})
describe('getDefaultPrimarySelectionMiddleClickPaste', () => {
it('enables primary selection paste on Linux by default', () => {
expect(getDefaultPrimarySelectionMiddleClickPaste('linux')).toBe(true)
})
it('leaves primary selection paste opt-in on macOS and Windows', () => {
expect(getDefaultPrimarySelectionMiddleClickPaste('darwin')).toBe(false)
expect(getDefaultPrimarySelectionMiddleClickPaste('win32')).toBe(false)
})
})
+5
View File
@@ -59,6 +59,10 @@ function defaultTerminalFontFamily(): string {
}
return 'SF Mono' // macOS default
}
export const getDefaultPrimarySelectionMiddleClickPaste = (
platform = typeof process !== 'undefined' ? process.platform : ''
): boolean => platform === 'linux'
/**
* Why: ProseMirror builds an in-memory tree for the entire document, so large
* markdown files cause noticeable typing lag in the rich editor. Files above
@@ -168,6 +172,7 @@ export function getDefaultSettings(homedir: string): GlobalSettings {
editorAutoSaveDelayMs: DEFAULT_EDITOR_AUTO_SAVE_DELAY_MS,
editorMinimapEnabled: false,
markdownReviewToolsEnabled: true,
primarySelectionMiddleClickPaste: getDefaultPrimarySelectionMiddleClickPaste(),
terminalFontSize: 14,
terminalFontFamily: defaultTerminalFontFamily(),
terminalFontWeight: DEFAULT_TERMINAL_FONT_WEIGHT,
+4
View File
@@ -1271,6 +1271,10 @@ export type GlobalSettings = {
editorMinimapEnabled: boolean
/** Whether local markdown review note controls and the review panel are shown. */
markdownReviewToolsEnabled: boolean
/** Why: mirrors X11 primary-selection muscle memory without mutating the
* normal system clipboard; Linux enables it by default, other platforms
* leave middle-click semantics unchanged unless the user opts in. */
primarySelectionMiddleClickPaste?: boolean
terminalFontSize: number
terminalFontFamily: string
terminalFontWeight: number