nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: sindresorhus/dot-prop
Pull request #86 (2021-09-08 03:17:41)

Return default value if path is invalid
This is the last untested part of the code (#70)

sindresorhus: > Can you do a new test (**with a descriptive title**)

Test, not assertion.

Patch:
diff --git a/index.js b/index.js
index e1f316f..3fe9b42 100644
--- a/index.js
+++ b/index.js
@@ -39,7 +39,7 @@ module.exports = {
 
 		const pathArray = getPathSegments(path);
 		if (pathArray.length === 0) {
-			return;
+			return value;
 		}
 
 		for (let i = 0; i < pathArray.length; i++) {


Test patch:
diff --git a/test.js b/test.js
index 0354205..a43c89e 100644
--- a/test.js
+++ b/test.js
@@ -213,3 +213,7 @@ test('prevent setting/getting `__proto__`', t => {
 
 	t.is(dotProp.get({}, '__proto__'), undefined);
 });
+
+test('return default value if path is invalid', t => {
+	t.is(dotProp.get({}, 'constructor', '🦄'), '🦄');
+});
Repository: sindresorhus/dot-prop
Pull request #89 (2022-01-01 17:18:11)

Fix crash when modifying array length
Also avoids unnecessary allocation and set.

Fixes cases like the following:
```javascript
let obj = { a: [1,2] };
dotProp.delete(obj, 'a.1');
dotProp.set(obj, 'a.length', 1);
```
Previously would throw `Uncaught RangeError: Invalid array length` when it tries to set `obj.a.length = {}`

sindresorhus: Can you add a test?
Jimbly: Merge conflicts resolved and test added (also verified the test still fails on `main`).

Patch:
diff --git a/index.js b/index.js
index abd5e30..11d9895 100644
--- a/index.js
+++ b/index.js
@@ -219,12 +219,10 @@ export function setProperty(object, path, value) {
 
 		assertNotStringIndex(object, key);
 
-		if (!isObject(object[key])) {
-			object[key] = typeof pathArray[index + 1] === 'number' ? [] : {};
-		}
-
 		if (index === pathArray.length - 1) {
 			object[key] = value;
+		} else if (!isObject(object[key])) {
+			object[key] = typeof pathArray[index + 1] === 'number' ? [] : {};
 		}
 
 		object = object[key];


Test patch:
diff --git a/test.js b/test.js
index 0430e58..5db7cc7 100644
--- a/test.js
+++ b/test.js
@@ -245,6 +245,11 @@ test('setProperty', t => {
 			bar: true,
 		}],
 	});
+
+	const fixture7 = {foo: ['bar', 'baz']};
+	setProperty(fixture7, 'foo.length', 1);
+	t.is(fixture7.foo.length, 1);
+	t.deepEqual(fixture7, {foo: ['bar']});
 });
 
 test('deleteProperty', t => {
Repository: sindresorhus/dot-prop
Pull request #110 (2023-07-04 18:33:00)

fix deepkeys for sparsed arrays
fix https://github.com/sindresorhus/dot-prop/issues/108 and https://github.com/sindresorhus/dot-prop/issues/109

sindresorhus: You also need to update the readme about sparse keys: https://github.com/sindresorhus/dot-prop#deepkeysobject

Patch:
diff --git a/index.js b/index.js
index e6a107f..acc3a53 100644
--- a/index.js
+++ b/index.js
@@ -295,12 +295,12 @@ export function escapePath(path) {
 
 // The keys returned by Object.entries() for arrays are strings
 function entries(value) {
+	const result = Object.entries(value);
 	if (Array.isArray(value)) {
-		// We use `[...value]` to convert sparse entries to normal ones.
-		return [...value].map((value, index) => [index, value]);
+		return result.map(([key, value]) => [Number(key), value]);
 	}
 
-	return Object.entries(value);
+	return result;
 }
 
 function stringifyPath(pathSegments) {
diff --git a/readme.md b/readme.md
index 5c7adf2..ebdc035 100644
--- a/readme.md
+++ b/readme.md
@@ -135,7 +135,7 @@ for (const property of deepKeys(user)) {
 }
 ```
 
-Sparse arrays are supported, but holes are filled. In general, [avoid using sparse arrays](https://github.com/sindresorhus/dot-prop/issues/109#issuecomment-1614819869).
+Sparse arrays are supported. In general, [avoid using sparse arrays](https://github.com/sindresorhus/dot-prop/issues/109#issuecomment-1614819869).
 
 #### object
 


Test patch:
diff --git a/test.js b/test.js
index 39655d7..b8415c1 100644
--- a/test.js
+++ b/test.js
@@ -473,7 +473,6 @@ test('deepKeys - does not throw on sparse array', t => {
 
 	t.deepEqual(keys, [
 		'sparse[0]',
-		'sparse[1]',
 		'sparse[2]',
 	]);
 });
Repository: withspectrum/draft-js-markdown-plugin
Pull request #55 (2018-04-13 14:45:39)

Create new code block on space
This means we don't require enter to create new code blocks, which solves a couple QoL issues. Ref withspectrum/spectrum#2854

/cc @brianlovin


Patch:
diff --git a/src/index.js b/src/index.js
index 0b9fc5d..4b0278d 100755
--- a/src/index.js
+++ b/src/index.js
@@ -109,6 +109,19 @@ function checkCharacterForState(config, editorState, character) {
   ) {
     newEditorState = handleLink(editorState, character);
   }
+  if (
+    newEditorState === editorState &&
+    config.features.block.includes("CODE")
+  ) {
+    const contentState = editorState.getCurrentContent();
+    const selection = editorState.getSelection();
+    const key = selection.getStartKey();
+    const currentBlock = contentState.getBlockForKey(key);
+    const text = currentBlock.getText();
+    const type = currentBlock.getType();
+    if (type !== "code-block" && CODE_BLOCK_REGEX.test(text))
+      newEditorState = handleNewCodeBlock(editorState);
+  }
   if (editorState === newEditorState) {
     newEditorState = handleInlineStyle(
       config.features.inline,


Test patch:
diff --git a/src/__test__/plugin.test.js b/src/__test__/plugin.test.js
index c7d4382..309e1fb 100755
--- a/src/__test__/plugin.test.js
+++ b/src/__test__/plugin.test.js
@@ -613,6 +613,27 @@ describe("draft-js-markdown-plugin", () => {
             expect(subject()).toBe("not-handled");
           });
         });
+        it("handles new code block on space", () => {
+          createMarkdownPlugin.__Rewire__("handleNewCodeBlock", modifierSpy); // eslint-disable-line no-underscore-dangle
+          currentRawContentState = {
+            entityMap: {},
+            blocks: [
+              {
+                key: "item1",
+                text: "```",
+                type: "unstyled",
+                depth: 0,
+                inlineStyleRanges: [],
+                entityRanges: [],
+                data: {},
+              },
+            ],
+          };
+          character = " ";
+          expect(subject()).toBe("handled");
+          expect(modifierSpy).toHaveBeenCalledTimes(1);
+          expect(store.setEditorState).toHaveBeenCalledWith(newEditorState);
+        });
       });
       describe("handlePastedText", () => {
         let pastedText;