From 44233f384e59c74b54bc2e6ca5e7d2c3c03db9de Mon Sep 17 00:00:00 2001 From: Menno Finlay-Smits Date: Tue, 12 Mar 2019 19:46:59 +1300 Subject: [PATCH] Fix merge issues in develop (#257) * Fix merge issues in develop * Add -timeout to go test The tests are timing out on TravisCI for some reason so a timeout has been added so that `go test` will dump out the goroutine stack traces when the tests are stuck. * gui.Close now wakes up main loop Without this, otherwise successful tests in main_test.go hang. * Use a longer timeout in case CI infrastructure is slow * Fix various gofmt issues Not sure how some of these crept in. --- Makefile | 2 +- buffer/buffer.go | 2 +- gui/gui.go | 3 ++- gui/input.go | 2 +- terminal/terminal.go | 11 +---------- windows/installer/installer.go | 30 +++++++++++++++--------------- windows/launcher/launcher.go | 6 +++--- windows/winutil/winutil.go | 2 +- 8 files changed, 25 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 3861ce8..6de5891 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ build: .PHONY: test test: - go test -v ./... + go test -v -timeout=8m ./... go vet -v .PHONY: check-gofmt diff --git a/buffer/buffer.go b/buffer/buffer.go index 57a7b35..201931a 100644 --- a/buffer/buffer.go +++ b/buffer/buffer.go @@ -874,7 +874,7 @@ func (buffer *Buffer) Clear() { } func (buffer *Buffer) ReallyClear() { - defer buffer.emitDisplayChange() + defer buffer.dirty.Notify() buffer.lines = []Line{} buffer.terminalState.SetScrollOffset(0) buffer.SetPosition(0, 0) diff --git a/gui/gui.go b/gui/gui.go index 0af42eb..bc7fbaa 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -326,6 +326,7 @@ func (gui *GUI) getTermSize() (uint, uint) { func (gui *GUI) Close() { gui.window.SetShouldClose(true) + glfw.PostEmptyEvent() // wake up main loop so it notices close request } func (gui *GUI) Render() error { @@ -436,7 +437,7 @@ func (gui *GUI) Render() error { go gui.waker(stop) for !gui.window.ShouldClose() { - gui.redraw() + gui.redraw(true) if gui.showDebugInfo { gui.textbox(2, 2, fmt.Sprintf(`Cursor: %d,%d diff --git a/gui/input.go b/gui/input.go index c5caada..ec7b65e 100644 --- a/gui/input.go +++ b/gui/input.go @@ -52,7 +52,7 @@ func (gui *GUI) updateSelectionMode(mods glfw.ModifierKey) { } if gui.selectionRegionMode != mode { gui.selectionRegionMode = mode - gui.terminal.SetDirty() + gui.terminal.NotifyDirty() } } diff --git a/terminal/terminal.go b/terminal/terminal.go index 1c50074..482cdc5 100644 --- a/terminal/terminal.go +++ b/terminal/terminal.go @@ -85,7 +85,7 @@ func New(pty platform.Pty, logger *zap.SugaredLogger, config *config.Config) *Te ShowCursor: true, }, platformDependentSettings: pty.GetPlatformDependentSettings(), - dirty: newNotifier(), + dirty: newNotifier(), } t.buffers = []*buffer.Buffer{ buffer.NewBuffer(t.terminalState, t.dirty), @@ -436,12 +436,3 @@ func (terminal *Terminal) Lock() { func (terminal *Terminal) Unlock() { terminal.lock.Unlock() } - -// SetDirtyLocked sets dirty flag locking the terminal to prevent data race warnings -// @todo remove when switching to event-driven architecture -func (terminal *Terminal) SetDirtyLocked() { - terminal.Lock() - defer terminal.Unlock() - - terminal.SetDirty() -} diff --git a/windows/installer/installer.go b/windows/installer/installer.go index 1d47f4b..9aba6d7 100644 --- a/windows/installer/installer.go +++ b/windows/installer/installer.go @@ -5,18 +5,18 @@ package main import ( "bufio" "errors" - "golang.org/x/sys/windows/registry" - "os" - "os/user" - "strings" - "path/filepath" - "github.com/liamg/aminal/windows/winutil" - "github.com/liamg/aminal/generated-src/installer/data" - "text/template" - "io/ioutil" - "os/exec" - "syscall" "flag" + "github.com/liamg/aminal/generated-src/installer/data" + "github.com/liamg/aminal/windows/winutil" + "golang.org/x/sys/windows/registry" + "io/ioutil" + "os" + "os/exec" + "os/user" + "path/filepath" + "strings" + "syscall" + "text/template" ) const Version = "VERSION" @@ -116,7 +116,7 @@ func createRegistryKeysForUninstaller(installDir string, isUserInstall bool) { func updateVersionInRegistry(isUserInstall bool) { regRoot := getRegistryRoot(isUserInstall) updateKey := `Software\Aminal\Update\Clients\` + ProductId - writeRegStr(regRoot, updateKey, "pv", Version + ".0") + writeRegStr(regRoot, updateKey, "pv", Version+".0") writeRegStr(regRoot, updateKey, "name", "Aminal") } @@ -128,7 +128,7 @@ func getRegistryRoot(isUserInstall bool) registry.Key { } func writeRegStr(regRoot registry.Key, keyPath string, valueName string, value string) { - const mode = registry.WRITE|registry.WOW64_32KEY + const mode = registry.WRITE | registry.WOW64_32KEY key, _, err := registry.CreateKey(regRoot, keyPath, mode) check(err) defer key.Close() @@ -154,7 +154,7 @@ func getStartMenuDir(isUserInstall bool) string { func createShortcut(linkPath, targetPath string) { type Shortcut struct { - LinkPath string + LinkPath string TargetPath string } tmpl := template.New("createLnk.vbs") @@ -215,4 +215,4 @@ func check(e error) { if e != nil { panic(e) } -} \ No newline at end of file +} diff --git a/windows/launcher/launcher.go b/windows/launcher/launcher.go index 73da185..cd5cc5f 100644 --- a/windows/launcher/launcher.go +++ b/windows/launcher/launcher.go @@ -19,6 +19,7 @@ package main import ( "errors" "fmt" + "github.com/liamg/aminal/windows/winutil" "io/ioutil" "os" "os/exec" @@ -26,12 +27,11 @@ import ( "sort" "strconv" "strings" - "github.com/liamg/aminal/windows/winutil" ) type Version struct { number [3]int - name string + name string } type Versions []Version @@ -121,4 +121,4 @@ func check(e error) { if e != nil { panic(e) } -} \ No newline at end of file +} diff --git a/windows/winutil/winutil.go b/windows/winutil/winutil.go index 99e7c5b..7536aaa 100644 --- a/windows/winutil/winutil.go +++ b/windows/winutil/winutil.go @@ -24,4 +24,4 @@ func GetExecutablePath() (string, error) { return "", e1 } return string(utf16.Decode(b[0:n])), nil -} \ No newline at end of file +}