Ignore pasted input while in Normal mode (#2059)
This commit is contained in:
1 parent
5b2d5ad99d
commit
5e24fd93d2
2 files changed
+12
No files matched your search
@@ -49,6 +49,7 @@ func run() {
|
|||||||
if gOpts.mouse {
|
if gOpts.mouse {
|
||||||
screen.EnableMouse()
|
screen.EnableMouse()
|
||||||
}
|
}
|
||||||
|
screen.EnablePaste()
|
||||||
|
|
||||||
ui := newUI(screen)
|
ui := newUI(screen)
|
||||||
nav := newNav(ui.wins[0].h)
|
nav := newNav(ui.wins[0].h)
|
||||||
|
|||||||
@@ -664,6 +664,7 @@ type ui struct {
|
|||||||
styles styleMap
|
styles styleMap
|
||||||
icons iconMap
|
icons iconMap
|
||||||
currentFile string
|
currentFile string
|
||||||
|
pasteEvent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newUI(screen tcell.Screen) *ui {
|
func newUI(screen tcell.Screen) *ui {
|
||||||
@@ -1398,6 +1399,10 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
|
|
||||||
switch tev := ev.(type) {
|
switch tev := ev.(type) {
|
||||||
case *tcell.EventKey:
|
case *tcell.EventKey:
|
||||||
|
if ui.pasteEvent {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// KeyRune is a regular character
|
// KeyRune is a regular character
|
||||||
if tev.Key() == tcell.KeyRune {
|
if tev.Key() == tcell.KeyRune {
|
||||||
switch {
|
switch {
|
||||||
@@ -1577,6 +1582,12 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
} else {
|
} else {
|
||||||
return &callExpr{"on-focus-lost", nil, 1}
|
return &callExpr{"on-focus-lost", nil, 1}
|
||||||
}
|
}
|
||||||
|
case *tcell.EventPaste:
|
||||||
|
if tev.Start() {
|
||||||
|
ui.pasteEvent = true
|
||||||
|
} else if tev.End() {
|
||||||
|
ui.pasteEvent = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user