Fix various linter and vet warnings

This commit is contained in:
Zachary Yedidia
2017-02-21 13:07:37 -05:00
parent 4d1ad52405
commit 043f7cdc47
8 changed files with 40 additions and 39 deletions

View 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()

View 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))

View 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)

View 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

View 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

View 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 (

View 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)

View 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!")
}
}
}