Skip to content
Myr

Always check hasPreviewWindow() before processing preview mouse events

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 95f186f · Browse files · 1 file+7 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−5 removed

  • other:+7 added−5 removed

1 file+7 added−5 removed

modified:src/terminal.go+7 added-5 removed
7182 unmodified lines
7183 pmx, pmy = mx, my7184 }7185 if !me.Down {7186 barDragging = false7187 pmx, pmy = -1, -17188 }7189 if !me.Down || !t.hasPreviewWindow() {7190 pbarDragging = false7191 pborderDragging = -17192 previewDraggingPos = -17190 pmx, pmy = -1, -17193 }71947195 // Scrolling7196 if me.S != 0 {
19 unmodified lines
7216 break7217 }72187219 // Preview dragging7218 if me.Down && (previewDraggingPos >= 0 || click && t.hasPreviewWindow() && t.pwindow.Enclose(my, mx)) {7220 if t.hasPreviewWindow() && me.Down && (previewDraggingPos >= 0 || click && t.pwindow.Enclose(my, mx)) {7221 if previewDraggingPos > 0 {7222 scrollPreviewBy(previewDraggingPos - my)7223 }7224 previewDraggingPos = my
1 unmodified line
7226 }72277228 // Preview scrollbar dragging7229 headerLines := t.activePreviewOpts.headerLines7228 pbarDragging = me.Down && (pbarDragging || click && t.hasPreviewWindow() && my >= t.pwindow.Top()+headerLines && my < t.pwindow.Top()+t.pwindow.Height() && mx == t.pwindow.Left()+t.pwindow.Width())7230 pbarDragging = t.hasPreviewWindow() && me.Down && (pbarDragging || click && my >= t.pwindow.Top()+headerLines && my < t.pwindow.Top()+t.pwindow.Height() && mx == t.pwindow.Left()+t.pwindow.Width())7231 if pbarDragging {7232 effectiveHeight := t.pwindow.Height() - headerLines7233 numLines := len(t.previewer.lines) - headerLines7234 barLength, _ := getScrollbar(1, numLines, effectiveHeight, min(numLines-effectiveHeight, t.previewer.offset-headerLines))
8 unmodified lines
7243 break7244 }72457246 // Preview border dragging (resizing)7245 if pborderDragging < 0 && click && t.hasPreviewWindow() {7247 if t.hasPreviewWindow() && pborderDragging < 0 && click {7248 switch t.activePreviewOpts.position {7249 case posUp:7250 if t.pborder.Enclose(my, mx) && my == t.pborder.Top()+t.pborder.Height()-1 {7251 pborderDragging = 0
20 unmodified lines
7272 }7273 }7274 }72757274 if pborderDragging >= 0 && t.hasPreviewWindow() {7276 if t.hasPreviewWindow() && pborderDragging >= 0 {7277 var newSize int7278 var prevSize int7279 switch t.activePreviewOpts.position {7280 case posLeft:
664 unmodified lines