Skip to content

Commit

Permalink
Merge pull request #7842 from ggbhat/lineWiseCopyCut-codemirror-setting
Browse files Browse the repository at this point in the history
Line wise copy cut(Ctrl-C) codemirror setting
  • Loading branch information
Steven Silvester committed Feb 3, 2020
2 parents e29a63c + c6a33a3 commit 28c6e6e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
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

0 comments on commit 28c6e6e

Please sign in to comment.