From 3b66a3364cf7c865fd94464a0c49b8fba0f1f00d Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sun, 29 Dec 2019 22:02:14 -0500 Subject: [PATCH] Fix some formatting --- internal/action/actions.go | 2 - internal/action/command.go | 66 +++++++++++++-------------- internal/action/infopane.go | 2 +- internal/action/terminal_supported.go | 3 +- internal/buffer/search.go | 2 +- internal/display/bufwindow.go | 8 ++-- 6 files changed, 40 insertions(+), 43 deletions(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index 85a62dde..ed2ad367 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -614,8 +614,6 @@ func (h *BufPane) Autocomplete() bool { // InsertTab inserts a tab or spaces func (h *BufPane) InsertTab() bool { b := h.Buf - l := b.LineBytes(h.Cursor.Y) - l = util.SliceStart(l, h.Cursor.X) indent := b.IndentString(util.IntOpt(b.Settings["tabsize"])) tabBytes := len(indent) bytesUntilIndent := tabBytes - (h.Cursor.GetVisualX() % tabBytes) diff --git a/internal/action/command.go b/internal/action/command.go index 2656e1da..31fc9f9c 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -35,37 +35,37 @@ var commands map[string]Command func InitCommands() { commands = map[string]Command{ - "set": Command{(*BufPane).SetCmd, OptionValueComplete}, - "reset": Command{(*BufPane).ResetCmd, OptionValueComplete}, - "setlocal": Command{(*BufPane).SetLocalCmd, OptionValueComplete}, - "show": Command{(*BufPane).ShowCmd, OptionComplete}, - "showkey": Command{(*BufPane).ShowKeyCmd, nil}, - "run": Command{(*BufPane).RunCmd, nil}, - "bind": Command{(*BufPane).BindCmd, nil}, - "unbind": Command{(*BufPane).UnbindCmd, nil}, - "quit": Command{(*BufPane).QuitCmd, nil}, - "goto": Command{(*BufPane).GotoCmd, nil}, - "save": Command{(*BufPane).SaveCmd, nil}, - "replace": Command{(*BufPane).ReplaceCmd, nil}, - "replaceall": Command{(*BufPane).ReplaceAllCmd, nil}, - "vsplit": Command{(*BufPane).VSplitCmd, buffer.FileComplete}, - "hsplit": Command{(*BufPane).HSplitCmd, buffer.FileComplete}, - "tab": Command{(*BufPane).NewTabCmd, buffer.FileComplete}, - "help": Command{(*BufPane).HelpCmd, HelpComplete}, - "eval": Command{(*BufPane).EvalCmd, nil}, - "log": Command{(*BufPane).ToggleLogCmd, nil}, - "plugin": Command{(*BufPane).PluginCmd, PluginComplete}, - "reload": Command{(*BufPane).ReloadCmd, nil}, - "reopen": Command{(*BufPane).ReopenCmd, nil}, - "cd": Command{(*BufPane).CdCmd, buffer.FileComplete}, - "pwd": Command{(*BufPane).PwdCmd, nil}, - "open": Command{(*BufPane).OpenCmd, buffer.FileComplete}, - "tabswitch": Command{(*BufPane).TabSwitchCmd, nil}, - "term": Command{(*BufPane).TermCmd, nil}, - "memusage": Command{(*BufPane).MemUsageCmd, nil}, - "retab": Command{(*BufPane).RetabCmd, nil}, - "raw": Command{(*BufPane).RawCmd, nil}, - "textfilter": Command{(*BufPane).TextFilterCmd, nil}, + "set": {(*BufPane).SetCmd, OptionValueComplete}, + "reset": {(*BufPane).ResetCmd, OptionValueComplete}, + "setlocal": {(*BufPane).SetLocalCmd, OptionValueComplete}, + "show": {(*BufPane).ShowCmd, OptionComplete}, + "showkey": {(*BufPane).ShowKeyCmd, nil}, + "run": {(*BufPane).RunCmd, nil}, + "bind": {(*BufPane).BindCmd, nil}, + "unbind": {(*BufPane).UnbindCmd, nil}, + "quit": {(*BufPane).QuitCmd, nil}, + "goto": {(*BufPane).GotoCmd, nil}, + "save": {(*BufPane).SaveCmd, nil}, + "replace": {(*BufPane).ReplaceCmd, nil}, + "replaceall": {(*BufPane).ReplaceAllCmd, nil}, + "vsplit": {(*BufPane).VSplitCmd, buffer.FileComplete}, + "hsplit": {(*BufPane).HSplitCmd, buffer.FileComplete}, + "tab": {(*BufPane).NewTabCmd, buffer.FileComplete}, + "help": {(*BufPane).HelpCmd, HelpComplete}, + "eval": {(*BufPane).EvalCmd, nil}, + "log": {(*BufPane).ToggleLogCmd, nil}, + "plugin": {(*BufPane).PluginCmd, PluginComplete}, + "reload": {(*BufPane).ReloadCmd, nil}, + "reopen": {(*BufPane).ReopenCmd, nil}, + "cd": {(*BufPane).CdCmd, buffer.FileComplete}, + "pwd": {(*BufPane).PwdCmd, nil}, + "open": {(*BufPane).OpenCmd, buffer.FileComplete}, + "tabswitch": {(*BufPane).TabSwitchCmd, nil}, + "term": {(*BufPane).TermCmd, nil}, + "memusage": {(*BufPane).MemUsageCmd, nil}, + "retab": {(*BufPane).RetabCmd, nil}, + "raw": {(*BufPane).RawCmd, nil}, + "textfilter": {(*BufPane).TextFilterCmd, nil}, } } @@ -240,7 +240,7 @@ func (h *BufPane) RawCmd(args []string) { // TextFilterCmd filters the selection through the command. // Selection goes to the command input. -// On successfull run command output replaces the current selection. +// On successful run command output replaces the current selection. func (h *BufPane) TextFilterCmd(args []string) { if len(args) == 0 { InfoBar.Error("usage: textfilter arguments") @@ -691,7 +691,7 @@ func (h *BufPane) BindCmd(args []string) { // UnbindCmd binds a key to its default action func (h *BufPane) UnbindCmd(args []string) { if len(args) < 1 { - InfoBar.Error("Not enough arguements") + InfoBar.Error("Not enough arguments") return } diff --git a/internal/action/infopane.go b/internal/action/infopane.go index 33b40268..00dde633 100644 --- a/internal/action/infopane.go +++ b/internal/action/infopane.go @@ -147,7 +147,7 @@ var InfoNones = []string{ "SkipMultiCursor", } -// InfoOverrides is the list of actions which have been overriden +// InfoOverrides is the list of actions which have been overridden // by the infohandler var InfoOverrides = map[string]InfoKeyAction{ "CursorUp": (*InfoPane).CursorUp, diff --git a/internal/action/terminal_supported.go b/internal/action/terminal_supported.go index 50e0a75d..21a6de0e 100644 --- a/internal/action/terminal_supported.go +++ b/internal/action/terminal_supported.go @@ -18,9 +18,8 @@ func RunTermEmulator(h *BufPane, input string, wait bool, getOutput bool, callba t := new(shell.Terminal) t.Start(args, getOutput, wait, callback, userargs) - id := h.ID() h.AddTab() - id = MainTab().Panes[0].ID() + id := MainTab().Panes[0].ID() v := h.GetView() MainTab().Panes[0] = NewTermPane(v.X, v.Y, v.Width, v.Height, t, id) diff --git a/internal/buffer/search.go b/internal/buffer/search.go index 4382971d..0930ba2c 100644 --- a/internal/buffer/search.go +++ b/internal/buffer/search.go @@ -115,7 +115,7 @@ func (b *Buffer) FindNext(s string, start, end, from Loc, down bool, useRegex bo return [2]Loc{}, false, err } - found := false + var found bool var l [2]Loc if down { l, found = b.findDown(r, from, end) diff --git a/internal/display/bufwindow.go b/internal/display/bufwindow.go index 3b478e7c..39934166 100644 --- a/internal/display/bufwindow.go +++ b/internal/display/bufwindow.go @@ -45,12 +45,12 @@ func (w *BufWindow) SetBuffer(b *buffer.Buffer) { w.Buf = b } -func (v *View) GetView() *View { - return v +func (w *BufWindow) GetView() *View { + return w.View } -func (v *View) SetView(view *View) { - v = view +func (w *BufWindow) SetView(view *View) { + w.View = view } func (w *BufWindow) Resize(width, height int) {