nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: cogentcore/core
Pull request #1043 (2024-07-24 16:22:15)

add lf at end of bytes -- turns out it is a standard..
https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline


Patch:
diff --git a/texteditor/text/lines.go b/texteditor/text/lines.go
index 53678e456..1fcbee3c2 100644
--- a/texteditor/text/lines.go
+++ b/texteditor/text/lines.go
@@ -137,6 +137,7 @@ func (ls *Lines) SetTextLines(lns [][]byte) {
 }
 
 // Bytes returns the current text lines as a slice of bytes,
+// with an additional line feed at the end, per POSIX standards.
 func (ls *Lines) Bytes() []byte {
 	ls.Lock()
 	defer ls.Unlock()
@@ -642,15 +643,10 @@ func (ls *Lines) initFromLineBytes() {
 }
 
 // bytes returns the current text lines as a slice of bytes.
+// with an additional line feed at the end, per POSIX standards.
 func (ls *Lines) bytes() []byte {
 	txt := bytes.Join(ls.lineBytes, []byte("\n"))
-	return txt
-}
-
-// bytesLF returns the current text lines as a slice of bytes,
-// with an additional line feed at the end, needed for passing code to markup.
-func (ls *Lines) bytesLF() []byte {
-	txt := ls.bytes()
+	// https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline
 	txt = append(txt, []byte("\n")...)
 	return txt
 }
@@ -1269,7 +1265,7 @@ func (ls *Lines) initialMarkup() {
 	}
 	if ls.Highlighter.UsingParse() {
 		fs := ls.ParseState.Done() // initialize
-		fs.Src.SetBytes(ls.bytesLF())
+		fs.Src.SetBytes(ls.bytes())
 	}
 	mxhi := min(100, ls.numLines())
 	txt := bytes.Join(ls.lineBytes[:mxhi], []byte("\n"))
@@ -1357,7 +1353,7 @@ func (ls *Lines) adjustedTagsLine(tags lexer.Line, ln int) lexer.Line {
 // Does not start or end with lock, but acquires at end to apply.
 func (ls *Lines) asyncMarkup() {
 	ls.Lock()
-	txt := ls.bytesLF()
+	txt := ls.bytes()
 	ls.markupEdits = nil // only accumulate after this point; very rare
 	ls.Unlock()
 


Test patch:
diff --git a/texteditor/editor_test.go b/texteditor/editor_test.go
index 68d606e0c..5ccd8a92a 100644
--- a/texteditor/editor_test.go
+++ b/texteditor/editor_test.go
@@ -85,7 +85,7 @@ func TestEditorChange(t *testing.T) {
 		mods.SetFlag(true, key.Control)
 		ed.HandleEvent(events.NewKey(events.KeyChord, 0, key.CodeReturnEnter, mods))
 		assert.Equal(t, 1, n)
-		assert.Equal(t, "Go\n", text)
+		assert.Equal(t, "Go\n\n", text)
 	})
 }
 
@@ -101,12 +101,12 @@ func TestEditorInput(t *testing.T) {
 	b.AssertRender(t, "input", func() {
 		ed.HandleEvent(events.NewKey(events.KeyChord, 'G', 0, 0))
 		assert.Equal(t, 1, n)
-		assert.Equal(t, "G", text)
+		assert.Equal(t, "G\n", text)
 		ed.HandleEvent(events.NewKey(events.KeyChord, 'o', 0, 0))
 		assert.Equal(t, 2, n)
-		assert.Equal(t, "Go", text)
+		assert.Equal(t, "Go\n", text)
 		ed.HandleEvent(events.NewKey(events.KeyChord, 0, key.CodeReturnEnter, 0))
 		assert.Equal(t, 3, n)
-		assert.Equal(t, "Go\n", text)
+		assert.Equal(t, "Go\n\n", text)
 	})
 }
Repository: cogentcore/core
Pull request #1397 (2024-12-23 22:19:51)

fix for FieldByPath
It was returning Addr to make sure values were directly copyable in SetFieldsFromMap, but that should happen by calling PointerValue there instead. Otherwise, this was causing the dreaded copy of image contents instead of pointers, corrupting the color scheme.


Patch:
diff --git a/base/reflectx/structs.go b/base/reflectx/structs.go
index f7c4a486d..6b46ffe12 100644
--- a/base/reflectx/structs.go
+++ b/base/reflectx/structs.go
@@ -245,7 +245,7 @@ func FieldByPath(s reflect.Value, fieldPath string) (reflect.Value, error) {
 		}
 		sv = fv
 	}
-	return sv.Addr(), nil
+	return sv, nil
 }
 
 // CopyFields copies the named fields from src struct into dest struct.
@@ -299,7 +299,7 @@ func SetFieldsFromMap(obj any, vals map[string]any) error {
 		if err != nil {
 			errs = append(errs, err)
 		}
-		err = SetRobust(fld.Interface(), v)
+		err = SetRobust(PointerValue(fld).Interface(), v)
 		if err != nil {
 			err = errors.Log(fmt.Errorf("SetFieldsFromMap: was not able to apply value: %v to field: %s", v, k))
 			errs = append(errs, err)


Test patch:
diff --git a/base/reflectx/structs_test.go b/base/reflectx/structs_test.go
index 05a479c4d..5a69b7660 100644
--- a/base/reflectx/structs_test.go
+++ b/base/reflectx/structs_test.go
@@ -104,10 +104,10 @@ func TestFieldByPath(t *testing.T) {
 	spv := reflect.ValueOf(sp)
 	fv, err := FieldByPath(spv, "Pet.Age")
 	assert.NoError(t, err)
-	assert.Equal(t, 7, fv.Elem().Interface())
+	assert.Equal(t, 7, fv.Interface())
 	fv, err = FieldByPath(spv, "Pet.Name")
 	assert.NoError(t, err)
-	assert.Equal(t, "Pet Gopher", fv.Elem().Interface())
+	assert.Equal(t, "Pet Gopher", fv.Interface())
 	fv, err = FieldByPath(spv, "Pet.Ages")
 	assert.Error(t, err)
 	fv, err = FieldByPath(spv, "Pets.Age")
Repository: cogentcore/core
Pull request #1459 (2025-01-26 23:12:39)

fix semicolon formatting in windowsRegistryAddPath
For #1384 


Patch:
diff --git a/cmd/core/cmd/registry_windows.go b/cmd/core/cmd/registry_windows.go
index 98683e1d6..19acbe698 100644
--- a/cmd/core/cmd/registry_windows.go
+++ b/cmd/core/cmd/registry_windows.go
@@ -28,11 +28,15 @@ func windowsRegistryAddPath(path string) error {
 		return err
 	}
 	scpath := ";" + path + ";"
-	if strings.Contains(s, scpath) {
+	if strings.Contains(s, scpath) || strings.HasPrefix(s, path+";") || strings.HasSuffix(s, ";"+path) {
 		fmt.Printf("Path %s already in existing Path: %s\n", path, s)
 		return nil
 	}
-	s += path + ";"
+	if strings.HasSuffix(s, ";") {
+		s += path + ";"
+	} else {
+		s += scpath
+	}
 	err = k.SetStringValue("Path", s)
 	if err != nil {
 		return err


Test patch:
diff --git a/cmd/core/cmd/registry_test.go b/cmd/core/cmd/registry_test.go
new file mode 100644
index 000000000..5e32ae548
--- /dev/null
+++ b/cmd/core/cmd/registry_test.go
@@ -0,0 +1,17 @@
+// Copyright (c) 2025, Cogent Core. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build windows && registrytest
+
+package cmd
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestRegistryWindows(t *testing.T) {
+	assert.NoError(t, windowsRegistryAddPath(`C:\w64devkit\bin`))
+}