Minor fixes

This commit is contained in:
akiyosi 2020-07-17 00:47:05 +09:00
parent d2f1b88dd1
commit 9fcf929cf6
9 changed files with 83 additions and 23 deletions

View file

@ -1,3 +1,60 @@
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
# - exhaustive
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
- misspell
- nakedret
# - noctx
- nolintlint
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
# don't enable:
# - asciicheck
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - maligned
# - nestif
# - prealloc
# - testpackage
# - wsl
# options for analysis running
run:
# default concurrency is a available CPU number

View file

@ -746,7 +746,7 @@ func (e *Editor) convertKey(event *gui.QKeyEvent) string {
text = strings.ToLower(text)
}
}
c = string(text)
c = text
if c == "" {
return ""
}

View file

@ -106,8 +106,8 @@ func TestDarwinEditor_convertKey(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if got := e.convertKey(tt.args); got != tt.want {
t.Errorf("Editor.convertKey() = %v, want %v", got, tt.want)
}

View file

@ -101,6 +101,7 @@ func TestEditor_convertKey(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
e := &Editor{}
e.InitSpecialKeys()

View file

@ -360,9 +360,11 @@ func (m *Message) makeMessage(kind string, attrId int, text string, length int,
}
}
MessageSignal := m.ws.signal.MessageSignal
item.hideAt = time.Now().Add(time.Duration(m.expires) * time.Second)
time.AfterFunc(time.Duration(m.expires+1)*time.Second, func() {
m.ws.signal.MessageSignal()
MessageSignal()
})
item.attrId = attrId
item.setKind(kind)

View file

@ -120,7 +120,7 @@ func (m *MiniMap) startMinimapProc() {
childProcessCmd := nvim.ChildProcessCommand(editor.opts.Nvim)
neovim, err = nvim.NewChildProcess(minimapProcessArgs, childProcessCmd)
} else {
// Attaching to nvim normaly
// Attaching to nvim normally
neovim, err = nvim.NewChildProcess(minimapProcessArgs)
}
if err != nil {
@ -455,7 +455,6 @@ func (m *MiniMap) handleRedraw(updates [][]interface{}) {
event := update[0].(string)
args := update[1:]
switch event {
case "grid_resize":
m.gridResize(args)
// case "default_colors_set":

View file

@ -468,7 +468,6 @@ func (s *Screen) toolTipPos() (int, int, int, int) {
y = ws.palette.patternPadding + ws.palette.padding
candY = y + ws.palette.widget.Pos().Y()
} else {
win, ok := s.getWindow(s.ws.cursor.gridid)
if !ok {
return 0, 0, 0, 0
@ -942,18 +941,18 @@ func (s *Screen) bottomWindowPos() int {
return pos
}
func (win *Window) wheelEvent(event *gui.QWheelEvent) {
func (w *Window) wheelEvent(event *gui.QWheelEvent) {
var v, h, vert, horiz int
var vertKey string
var horizKey string
font := win.getFont()
font := w.getFont()
// Detect current mode
mode := win.s.ws.mode
mode := w.s.ws.mode
if mode == "terminal-input" {
win.s.ws.nvim.Input(`<C-\><C-n>`)
w.s.ws.nvim.Input(`<C-\><C-n>`)
} else if mode != "normal" {
win.s.ws.nvim.Input(win.s.ws.escKeyInInsert)
w.s.ws.nvim.Input(w.s.ws.escKeyInInsert)
}
pixels := event.PixelDelta()
@ -965,10 +964,10 @@ func (win *Window) wheelEvent(event *gui.QWheelEvent) {
isStopScroll := event.Phase() == core.Qt__ScrollEnd
if (v == 0 || h == 0) && isStopScroll {
vert, horiz = win.smoothUpdate(v, h, isStopScroll)
vert, horiz = w.smoothUpdate(v, h, isStopScroll)
} else if (v != 0 || h != 0) && event.Phase() != core.Qt__NoScrollPhase {
// If Scrolling has ended, reset the displacement of the line
vert, horiz = win.smoothUpdate(v, h, isStopScroll)
vert, horiz = w.smoothUpdate(v, h, isStopScroll)
} else {
vert = angles.Y()
horiz = angles.X()
@ -1008,11 +1007,11 @@ func (win *Window) wheelEvent(event *gui.QWheelEvent) {
}
// If the window at the mouse pointer is not the current window
if win.grid != win.s.ws.cursor.gridid {
if w.grid != w.s.ws.cursor.gridid {
errCh := make(chan error, 60)
var err error
go func() {
err = win.s.ws.nvim.SetCurrentWindow(win.id)
err = w.s.ws.nvim.SetCurrentWindow(w.id)
errCh <-err
}()
@ -1025,15 +1024,15 @@ func (win *Window) wheelEvent(event *gui.QWheelEvent) {
mod := event.Modifiers()
if win.s.ws.isMappingScrollKey {
if w.s.ws.isMappingScrollKey {
if vert != 0 {
win.s.ws.nvim.Input(fmt.Sprintf("<%sScrollWheel%s>", editor.modPrefix(mod), vertKey))
w.s.ws.nvim.Input(fmt.Sprintf("<%sScrollWheel%s>", editor.modPrefix(mod), vertKey))
}
} else {
if vert > 0 {
win.s.ws.nvim.Input(fmt.Sprintf("%v<C-y>", int(math.Abs(float64(vert)))))
w.s.ws.nvim.Input(fmt.Sprintf("%v<C-y>", int(math.Abs(float64(vert)))))
} else if vert < 0 {
win.s.ws.nvim.Input(fmt.Sprintf("%v<C-e>", int(math.Abs(float64(vert)))))
w.s.ws.nvim.Input(fmt.Sprintf("%v<C-e>", int(math.Abs(float64(vert)))))
}
}
@ -1044,10 +1043,10 @@ func (win *Window) wheelEvent(event *gui.QWheelEvent) {
x := int(float64(event.X()) / font.truewidth)
y := int(float64(event.Y()) / float64(font.lineHeight))
pos := []int{x+win.pos[0], y+win.pos[1]}
pos := []int{x+w.pos[0], y+w.pos[1]}
if horiz != 0 {
win.s.ws.nvim.Input(fmt.Sprintf("<%sScrollWheel%s><%d,%d>", editor.modPrefix(mod), horizKey, pos[0], pos[1]))
w.s.ws.nvim.Input(fmt.Sprintf("<%sScrollWheel%s><%d,%d>", editor.modPrefix(mod), horizKey, pos[0], pos[1]))
}
event.Accept()
@ -2763,7 +2762,7 @@ func (s *Screen) gridDestroy(args []interface{}) {
continue
}
// NOTE: what should we actualy do in the event ??
// NOTE: what should we actually do in the event ??
win, ok := s.getWindow(gridid)
if !ok {
continue

View file

@ -72,6 +72,7 @@ func TestHighlight_fg(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
hl := &Highlight{
id: tt.fields.id,
@ -310,6 +311,7 @@ func TestWindow_updateLine(t *testing.T) {
// Do tests
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
w := &Window{
s: tt.fields.s,

View file

@ -318,7 +318,7 @@ func (w *Workspace) startNvim(path string) error {
childProcessCmd := nvim.ChildProcessCommand(editor.opts.Nvim)
neovim, err = nvim.NewChildProcess(childProcessArgs, childProcessCmd)
} else {
// Attaching to nvim normaly
// Attaching to nvim normally
neovim, err = nvim.NewChildProcess(childProcessArgs)
}
if err != nil {