@@ -56,14 +56,8 @@ const setCaretPosition = (ctrl: HTMLInputElement, pos: number) => {
56
56
const setCaretPositionToEnd = ( input : HTMLInputElement ) => setCaretPosition ( input , input . value . length )
57
57
58
58
/** Update the given input to reflect the given HistoryLine */
59
- const updateInputAndMoveCaretToEOL = (
60
- input : Input ,
61
- entry : HistoryLine ,
62
- dir : 'first' | 'last' | 'previous' | 'next'
63
- ) => {
64
- if ( input . props . isPartOfMiniSplit && input . props . navigateTo && input . props . idx > 0 ) {
65
- input . props . navigateTo ( dir )
66
- } else if ( entry ) {
59
+ const updateInputAndMoveCaretToEOL = ( input : Input , entry : HistoryLine ) => {
60
+ if ( entry ) {
67
61
input . state . prompt . value = entry . raw
68
62
setTimeout ( ( ) => setCaretPositionToEnd ( input . state . prompt ) , 0 )
69
63
} else {
@@ -90,7 +84,7 @@ export default async function onKeyDown(this: Input, event: KeyboardEvent) {
90
84
const historyModel = await ( await import ( '@kui-shell/core' ) ) . History ( tab )
91
85
const entry = historyModel . previous ( )
92
86
if ( entry ) {
93
- updateInputAndMoveCaretToEOL ( this , entry , 'previous' )
87
+ updateInputAndMoveCaretToEOL ( this , entry )
94
88
}
95
89
} else if ( char === KeyCodes . D && event . ctrlKey ) {
96
90
if ( prompt . value === '' ) {
@@ -103,12 +97,18 @@ export default async function onKeyDown(this: Input, event: KeyboardEvent) {
103
97
debug ( 'pageup' )
104
98
const { height } = document . body . getBoundingClientRect ( )
105
99
document . querySelector ( '.kui--tab-content.visible .repl-inner' ) . scrollBy ( 0 , - height )
100
+ } else if ( this . props . isPartOfMiniSplit ) {
101
+ // in minisplits, pageup means navigate to previous Block
102
+ this . props . navigateTo ( 'previous' )
106
103
}
107
104
} else if ( char === KeyCodes . PAGEDOWN ) {
108
105
if ( inBrowser ( ) ) {
109
106
debug ( 'pagedown' )
110
107
const { height } = document . body . getBoundingClientRect ( )
111
108
document . querySelector ( '.kui--tab-content.visible .repl-inner' ) . scrollBy ( 0 , + height )
109
+ } else if ( this . props . isPartOfMiniSplit ) {
110
+ // in minisplits, pageup means navigate to next Block
111
+ this . props . navigateTo ( 'next' )
112
112
}
113
113
} else if ( char === KeyCodes . C && event . ctrlKey ) {
114
114
// Ctrl+C, cancel
@@ -133,18 +133,18 @@ export default async function onKeyDown(this: Input, event: KeyboardEvent) {
133
133
const historyModel = await ( await import ( '@kui-shell/core' ) ) . History ( tab )
134
134
const entry = historyModel . first ( )
135
135
if ( entry ) {
136
- updateInputAndMoveCaretToEOL ( this , entry , 'first' )
136
+ updateInputAndMoveCaretToEOL ( this , entry )
137
137
}
138
138
} else if ( char === KeyCodes . END ) {
139
139
// go to last command in history
140
140
const historyModel = await ( await import ( '@kui-shell/core' ) ) . History ( tab )
141
141
const entry = historyModel . last ( )
142
- updateInputAndMoveCaretToEOL ( this , entry , 'last' )
142
+ updateInputAndMoveCaretToEOL ( this , entry )
143
143
} else if ( char === KeyCodes . DOWN || ( char === KeyCodes . N && event . ctrlKey ) ) {
144
144
// going DOWN past the last history item will result in '', i.e. a blank line
145
145
const historyModel = await ( await import ( '@kui-shell/core' ) ) . History ( tab )
146
146
const entry = historyModel . next ( )
147
- updateInputAndMoveCaretToEOL ( this , entry , 'next' )
147
+ updateInputAndMoveCaretToEOL ( this , entry )
148
148
} else if ( event . key === 'w' && event . ctrlKey ) {
149
149
const { prompt } = this . state
150
150
const idx = prompt . value . lastIndexOf (
0 commit comments