дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 11:15:40 +02:00
fix(editor): Count wide characters as two columns in column editing (#172)
Column-based editing computed columns with countColumn / findColumn, which count every grapheme as one column, and up/down and Clone Caret moved by pixel x, so block selections and cloned carets drifted on lines with CJK, fullwidth punctuation, Hangul, kana or emoji. A shared visible-column helper (UI side only, UTF-16 offsets in and out) now counts East Asian wide/fullwidth characters and emoji (ZWJ sequences, modifiers, flags, VS16) as 2, combining marks and format characters as 0, and expands tabs to the next tab stop. It drives Alt+drag block selection, drag and Shift+arrows in Column Selection Mode, middle-drag block selection (new; not on Linux, where middle-click pastes the primary selection), the up/down goal column (kept across short lines; soft-wrapped and folded lines still move visually), Clone Caret Above/Below, the caret move after Comment Line, Tab padding to the next indent stop, and macro playback of arrow keys. Claude-Session: https://claude.ai/code/session_01Dq6jQQn8ZhRfkkyj3PRutA
Цей коміт міститься в:
1 джерело
9c3347df95
коміт
c6621c5c36
15 files changed
+613
-58
No files matched your search
@@ -3,11 +3,14 @@
|
||||
* Those keys belong to IDE actions instead (keymaps in `platform/keymaps/`):
|
||||
* ⌘/Ctrl+Enter is Split Line, Ctrl+M / ⌃L Scroll to Center, Ctrl+[ / ] code
|
||||
* block navigation, ⌥⌘↑↓ / Ctrl+Alt+↑↓ Previous / Next Occurrence.
|
||||
* Line up / down (with ⇧ too) keep the caret's visible column (`verticalMotion`).
|
||||
*/
|
||||
import type { KeyBinding } from "@codemirror/view";
|
||||
import type { Command, KeyBinding } from "@codemirror/view";
|
||||
import {
|
||||
addCursorAbove,
|
||||
addCursorBelow,
|
||||
cursorLineDown as cmCursorLineDown,
|
||||
cursorLineUp as cmCursorLineUp,
|
||||
defaultKeymap,
|
||||
historyKeymap,
|
||||
indentLess,
|
||||
@@ -15,8 +18,11 @@ import {
|
||||
insertBlankLine,
|
||||
redo,
|
||||
selectLine,
|
||||
selectLineDown as cmSelectLineDown,
|
||||
selectLineUp as cmSelectLineUp,
|
||||
toggleTabFocusMode,
|
||||
} from "@codemirror/commands";
|
||||
import { cursorLineDown, cursorLineUp, selectLineDown, selectLineUp } from "./verticalMotion";
|
||||
|
||||
const DROPPED = new Set<unknown>([
|
||||
insertBlankLine, // Mod-Enter
|
||||
@@ -28,8 +34,20 @@ const DROPPED = new Set<unknown>([
|
||||
indentMore, // Mod-]
|
||||
]);
|
||||
|
||||
const VERTICAL = new Map<Command | undefined, Command>([
|
||||
[cmCursorLineUp, cursorLineUp],
|
||||
[cmCursorLineDown, cursorLineDown],
|
||||
[cmSelectLineUp, selectLineUp],
|
||||
[cmSelectLineDown, selectLineDown],
|
||||
]);
|
||||
|
||||
const vertical = (b: KeyBinding): KeyBinding =>
|
||||
VERTICAL.has(b.run) || VERTICAL.has(b.shift)
|
||||
? { ...b, run: VERTICAL.get(b.run) ?? b.run, shift: VERTICAL.get(b.shift) ?? b.shift }
|
||||
: b;
|
||||
|
||||
export const editorBaseKeymap: readonly KeyBinding[] = [
|
||||
...defaultKeymap.filter((b) => !DROPPED.has(b.run)),
|
||||
...defaultKeymap.filter((b) => !DROPPED.has(b.run)).map(vertical),
|
||||
...historyKeymap,
|
||||
// IDEA's Windows Redo is Ctrl+Shift+Z (Ctrl+Y is Delete Line); CodeMirror only binds it on macOS and Linux.
|
||||
{ win: "Ctrl-Shift-z", run: redo, preventDefault: true },
|
||||
|
||||
Reference in new issue
Заблокувати користувача