Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line wise copy cut(Ctrl-C) codemirror setting #7842

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/codemirror-extension/schema/commands.json
Expand Up @@ -39,6 +39,12 @@
"title": "Selection Pointer",
"description": "Value is boolean or string, e.g. 'pointer'",
"default": false
},
"lineWiseCopyCut": {
"type": ["boolean"],
"title": "Ctrl-C",
"description": "When enabled, which is the default, doing copy or cut when there is no selection will copy or cut the whole lines that have cursors on them.",
"default": true
}
},
"type": "object"
Expand Down
13 changes: 9 additions & 4 deletions packages/codemirror-extension/src/index.ts
Expand Up @@ -148,7 +148,8 @@ function activateEditorCommands(
scrollPastEnd,
styleActiveLine,
styleSelectedText,
selectionPointer
selectionPointer,
lineWiseCopyCut
} = CodeMirrorEditor.defaultConfig;

/**
Expand All @@ -172,13 +173,15 @@ function activateEditorCommands(
styleActiveLine =
(settings.get('styleActiveLine').composite as
| boolean
| CodeMirror.StyleActiveLine) || styleActiveLine;
| CodeMirror.StyleActiveLine) ?? styleActiveLine;
styleSelectedText =
(settings.get('styleSelectedText').composite as boolean) ||
(settings.get('styleSelectedText').composite as boolean) ??
styleSelectedText;
selectionPointer =
(settings.get('selectionPointer').composite as boolean | string) ||
(settings.get('selectionPointer').composite as boolean | string) ??
selectionPointer;
lineWiseCopyCut =
(settings.get('lineWiseCopyCut').composite as boolean) ?? lineWiseCopyCut;
}

/**
Expand All @@ -194,6 +197,7 @@ function activateEditorCommands(
cm.setOption('styleActiveLine', styleActiveLine);
cm.setOption('styleSelectedText', styleSelectedText);
cm.setOption('selectionPointer', selectionPointer);
cm.setOption('lineWiseCopyCut', lineWiseCopyCut);
}
});
}
Expand Down Expand Up @@ -225,6 +229,7 @@ function activateEditorCommands(
cm.setOption('styleActiveLine', styleActiveLine);
cm.setOption('styleSelectedText', styleSelectedText);
cm.setOption('selectionPointer', selectionPointer);
cm.setOption('lineWiseCopyCut', lineWiseCopyCut);
}
});

Expand Down
12 changes: 9 additions & 3 deletions packages/notebook-extension/schema/tracker.json
Expand Up @@ -267,6 +267,9 @@
},
"codeFolding": {
"type": "boolean"
},
"lineWiseCopyCut": {
"type": "boolean"
}
},
"additionalProperties": false,
Expand All @@ -291,7 +294,8 @@
"tabSize": 4,
"wordWrapColumn": 80,
"rulers": [],
"codeFolding": false
"codeFolding": false,
"lineWiseCopyCut": true
}
},
"defaultCell": {
Expand Down Expand Up @@ -324,7 +328,8 @@
"tabSize": 4,
"wordWrapColumn": 80,
"rulers": [],
"codeFolding": false
"codeFolding": false,
"lineWiseCopyCut": true
}
},
"rawCellConfig": {
Expand All @@ -344,7 +349,8 @@
"tabSize": 4,
"wordWrapColumn": 80,
"rulers": [],
"codeFolding": false
"codeFolding": false,
"lineWiseCopyCut": true
}
},
"scrollPastEnd": {
Expand Down