-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep current cursor or top line in view when resizing Console to avoi…
…d losing user context (#13695) * keep current cursor or top line in view when resizing to avoid losing user context * rename variable to more descriptive name * move state from editor to smart_resize
- Loading branch information
Showing
2 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
import { throttle } from 'lodash'; | ||
import { get, throttle } from 'lodash'; | ||
|
||
export default function (editor) { | ||
const resize = editor.resize; | ||
return throttle(() => resize.call(editor), 35) | ||
const throttledResize = throttle(() => { | ||
|
||
resize.call(editor); | ||
|
||
// Keep current top line in view when resizing to avoid losing user context | ||
let userRow = get(throttledResize, 'topRow', 0); | ||
if (userRow !== 0) { | ||
editor.renderer.scrollToLine(userRow, false, false, () => {}); | ||
} | ||
}, 35); | ||
return throttledResize; | ||
} |