Explorar el Código

Merge pull request #7842 from ggbhat/lineWiseCopyCut-codemirror-setting

Line wise copy cut(Ctrl-C) codemirror setting
Steven Silvester hace 5 años
padre
commit
28c6e6e96a

+ 6 - 0
packages/codemirror-extension/schema/commands.json

@@ -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"

+ 9 - 4
packages/codemirror-extension/src/index.ts

@@ -148,7 +148,8 @@ function activateEditorCommands(
     scrollPastEnd,
     styleActiveLine,
     styleSelectedText,
-    selectionPointer
+    selectionPointer,
+    lineWiseCopyCut
   } = CodeMirrorEditor.defaultConfig;
 
   /**
@@ -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;
   }
 
   /**
@@ -194,6 +197,7 @@ function activateEditorCommands(
         cm.setOption('styleActiveLine', styleActiveLine);
         cm.setOption('styleSelectedText', styleSelectedText);
         cm.setOption('selectionPointer', selectionPointer);
+        cm.setOption('lineWiseCopyCut', lineWiseCopyCut);
       }
     });
   }
@@ -225,6 +229,7 @@ function activateEditorCommands(
       cm.setOption('styleActiveLine', styleActiveLine);
       cm.setOption('styleSelectedText', styleSelectedText);
       cm.setOption('selectionPointer', selectionPointer);
+      cm.setOption('lineWiseCopyCut', lineWiseCopyCut);
     }
   });
 

+ 9 - 3
packages/notebook-extension/schema/tracker.json

@@ -267,6 +267,9 @@
         },
         "codeFolding": {
           "type": "boolean"
+        },
+        "lineWiseCopyCut": {
+          "type": "boolean"
         }
       },
       "additionalProperties": false,
@@ -291,7 +294,8 @@
         "tabSize": 4,
         "wordWrapColumn": 80,
         "rulers": [],
-        "codeFolding": false
+        "codeFolding": false,
+        "lineWiseCopyCut": true
       }
     },
     "defaultCell": {
@@ -324,7 +328,8 @@
         "tabSize": 4,
         "wordWrapColumn": 80,
         "rulers": [],
-        "codeFolding": false
+        "codeFolding": false,
+        "lineWiseCopyCut": true
       }
     },
     "rawCellConfig": {
@@ -344,7 +349,8 @@
         "tabSize": 4,
         "wordWrapColumn": 80,
         "rulers": [],
-        "codeFolding": false
+        "codeFolding": false,
+        "lineWiseCopyCut": true
       }
     },
     "scrollPastEnd": {