]> git.lizzy.rs Git - micro.git/commitdiff
Fix various linter and vet warnings
authorZachary Yedidia <zyedidia@gmail.com>
Tue, 21 Feb 2017 18:07:37 +0000 (13:07 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Tue, 21 Feb 2017 18:07:37 +0000 (13:07 -0500)
cmd/micro/actions.go
cmd/micro/autocomplete.go
cmd/micro/bindings.go
cmd/micro/lineArray.go
cmd/micro/plugin.go
cmd/micro/split_tree.go
cmd/micro/tab.go
tools/info-plist.go

index 5e7c52acde607b5bf009326d670e157c071273b7..4f2411ac451d0aad70ec45030392d08415044810 100644 (file)
@@ -464,7 +464,7 @@ func (v *View) InsertNewline(usePlugin bool) bool {
                }
 
                // Remove the whitespaces if keepautoindent setting is off
-               if IsSpacesOrTabs(v.Buf.Line(v.Cursor.Y - 1)) && !v.Buf.Settings["keepautoindent"].(bool) {
+               if IsSpacesOrTabs(v.Buf.Line(v.Cursor.Y-1)) && !v.Buf.Settings["keepautoindent"].(bool) {
                        line := v.Buf.Line(v.Cursor.Y - 1)
                        v.Buf.Remove(Loc{0, v.Cursor.Y - 1}, Loc{Count(line), v.Cursor.Y - 1})
                }
@@ -1445,9 +1445,10 @@ func (v *View) QuitAll(usePlugin bool) bool {
 
        if closeAll {
                // only quit if all of the buffers can be closed and the user confirms that they actually want to quit everything
-               should_quit, _ := messenger.YesNoPrompt("Do you want to quit micro (all open files will be closed)?")
-               
-               if should_quit {
+
+               shouldQuit, _ := messenger.YesNoPrompt("Do you want to quit micro (all open files will be closed)?")
+
+               if shouldQuit {
                        for _, tab := range tabs {
                                for _, v := range tab.views {
                                        v.CloseBuffer()
index 47aeca7344821599c1eeec04dceec401aa3bcb44..b1557e070efded79268de02cfe9da0569f2738ba 100644 (file)
@@ -129,7 +129,7 @@ func OptionComplete(input string) (string, []string) {
        return chosen, suggestions
 }
 
-// MakeCompletion registeres a function from a plugin for autocomplete commands
+// MakeCompletion registers a function from a plugin for autocomplete commands
 func MakeCompletion(function string) Completion {
        pluginCompletions = append(pluginCompletions, LuaFunctionComplete(function))
        return Completion(-len(pluginCompletions))
index 8cfe01c52cfc8d95da8f274a30b960caeb3398f5..9c813f0652e22669556e5f6b9672f98b3998d42e 100644 (file)
@@ -350,7 +350,7 @@ func BindKey(k, v string) {
        if helpBinding == k && v != "ToggleHelp" {
                helpBinding = ""
        }
-       
+
        actionNames := strings.Split(v, ",")
        if actionNames[0] == "UnbindKey" {
                delete(bindings, key)
index 9583c04ed9fd28b1434a290fef71677a50a3e174..6d62663d49447ecd64d0349803b342195e76e906 100644 (file)
@@ -44,7 +44,7 @@ func NewLineArray(reader io.Reader) *LineArray {
                data, err := br.ReadBytes('\n')
                if err != nil {
                        if err == io.EOF {
-                               la.lines = append(la.lines, data[:len(data)])
+                               la.lines = append(la.lines, data[:])
                        }
                        // Last line was read
                        break
index 4e8bfddeda143e6f9fc7658e44119c19009801c1..eba09f33e662e4cd89dd53330c08a8b7bd4da6d7 100644 (file)
@@ -6,8 +6,8 @@ import (
        "os"
        "strings"
 
-       "layeh.com/gopher-luar"
        "github.com/yuin/gopher-lua"
+       "layeh.com/gopher-luar"
 )
 
 var loadedPlugins map[string]string
index 60a431b4938b3a335fec872f479a7cb89693db0e..c089fd8fd94084c785d5f537d4b8e316113135f6 100644 (file)
@@ -1,6 +1,6 @@
 package main
 
-// SpltType specifies whether a split is horizontal or vertical
+// SplitType specifies whether a split is horizontal or vertical
 type SplitType bool
 
 const (
index 90e1220c1f8f7f8ddef75dc0af8db8019b067024..bbdd7eb0cffcad1169dfd922cba54ff2ce3bbd9d 100644 (file)
@@ -120,7 +120,7 @@ func TabbarHandleMouseEvent(event tcell.Event) bool {
                                return false
                        }
                        str, indicies := TabbarString()
-                       if x + tabBarOffset >= len(str) {
+                       if x+tabBarOffset >= len(str) {
                                return false
                        }
                        var tabnum int
@@ -130,7 +130,7 @@ func TabbarHandleMouseEvent(event tcell.Event) bool {
                        }
                        sort.Ints(keys)
                        for _, k := range keys {
-                               if x + tabBarOffset <= k {
+                               if x+tabBarOffset <= k {
                                        tabnum = indicies[k] - 1
                                        break
                                }
@@ -167,7 +167,7 @@ func DisplayTabs() {
        if tooWide == true {
                // first we have to work out where the selected tab is
                // out of the total length of the tab bar. this is done
-               // by extracting the hit-areas from the indicies map 
+               // by extracting the hit-areas from the indicies map
                // that was constructed by `TabbarString()`
                var keys []int
                for offset := range indicies {
@@ -197,7 +197,7 @@ func DisplayTabs() {
                rightBuffer := currentTabOffset + (centeringOffset / 2)
 
                // check to make sure we haven't overshot the bounds of the string,
-               // if we have, then take that remainder and put it on the left side 
+               // if we have, then take that remainder and put it on the left side
                overshotRight := rightBuffer - len(fileRunes)
                if overshotRight > 0 {
                        leftBuffer = leftBuffer + overshotRight
@@ -210,12 +210,12 @@ func DisplayTabs() {
                } else {
                        rightBuffer = leftBuffer + (w - 2)
                }
-               
-               if rightBuffer > len(fileRunes) - 1 {
+
+               if rightBuffer > len(fileRunes)-1 {
                        rightBuffer = len(fileRunes) - 1
                }
 
-               // construct a new buffer of text to put the 
+               // construct a new buffer of text to put the
                // newly formatted tab bar text into.
                var displayText []rune
 
@@ -232,13 +232,13 @@ func DisplayTabs() {
                }
                // if there is more text to the right of the right-most
                // column in the tab bar text, then indicate there are more
-               // tabs to ther right by displaying a "+"
-               if rightBuffer < len(fileRunes) - 1 {
+               // tabs to the right by displaying a "+"
+               if rightBuffer < len(fileRunes)-1 {
                        displayText = append(displayText, '+')
                }
 
                // now store the offset from zero of the left-most text
-               // that is being displayed. This is to ensure that when 
+               // that is being displayed. This is to ensure that when
                // clicking on the tab bar, the correct tab gets selected.
                tabBarOffset = leftBuffer
 
@@ -250,7 +250,7 @@ func DisplayTabs() {
        }
 
        // iterate over the width of the terminal display and for each column,
-       // write a character into the tab display area with the appropraite style.
+       // write a character into the tab display area with the appropriate style.
        for x := 0; x < w; x++ {
                if x < len(fileRunes) {
                        screen.SetContent(x, 0, fileRunes[x], nil, tabBarStyle)
index b16a8aeea4858a42a65cc83c800a25eccb021822..231901aaa4eaabe0cbfae0cb678bdb0826afcf08 100644 (file)
@@ -1,22 +1,22 @@
 package main
 
 import (
-    "os"
-    "fmt"
-    "runtime"
-    "io/ioutil"
+       "fmt"
+       "io/ioutil"
+       "os"
+       "runtime"
 )
 
 func check(e error) {
-    if e != nil {
-        panic(e)
-    }
+       if e != nil {
+               panic(e)
+       }
 }
 
 func main() {
-    if runtime.GOOS == "darwin" {
-        if len(os.Args) == 2 {
-            raw_info_plist_string := `<?xml version="1.0" encoding="UTF-8"?>
+       if runtime.GOOS == "darwin" {
+               if len(os.Args) == 2 {
+                       rawInfoPlistString := `<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
@@ -33,13 +33,13 @@ func main() {
 </dict>
 </plist>
 `
-            info_plist_data := []byte(raw_info_plist_string)
-            
-            err := ioutil.WriteFile("/tmp/micro-info.plist", info_plist_data, 0644)
-            check(err)
-            fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist")
-        } else {
-            panic("missing argument for version number!")
-        }
-    }
+                       infoPlistData := []byte(rawInfoPlistString)
+
+                       err := ioutil.WriteFile("/tmp/micro-info.plist", infoPlistData, 0644)
+                       check(err)
+                       fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist")
+               } else {
+                       panic("missing argument for version number!")
+               }
+       }
 }