0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Keep the cursor in the active view page after a divider width change.

Solves #2963
This commit is contained in:
David Bolack
2025-07-30 12:28:06 -05:00
parent 253dbb358b
commit 4aadb0b238
2 changed files with 12 additions and 2 deletions

View File

@@ -86,7 +86,7 @@ const SplitPane = (props)=>{
return (
<div className='splitPane' onPointerMove={handleMove} onPointerUp={handleUp}>
<Pane width={dividerPos} moveBrew={moveBrew} moveSource={moveSource} liveScroll={liveScroll} setMoveArrows={setShowMoveArrows}>
<Pane width={dividerPos} isDragging={isDragging} moveBrew={moveBrew} moveSource={moveSource} liveScroll={liveScroll} setMoveArrows={setShowMoveArrows}>
{props.children[0]}
</Pane>
{renderDivider}
@@ -102,7 +102,7 @@ const Pane = ({ width, children, isDragging, moveBrew, moveSource, liveScroll, s
return (
<div className='pane' style={styles}>
{React.cloneElement(children, { moveBrew, moveSource, liveScroll, setMoveArrows })}
{React.cloneElement(children, { moveBrew, moveSource, liveScroll, isDragging, setMoveArrows })}
</div>
);
};

View File

@@ -100,6 +100,16 @@ const Editor = createClass({
if(prevProps.moveSource !== this.props.moveSource)
this.sourceJump();
if((prevProps.isDragging !== this.props.isDragging) && (this.props.isDragging) && (this.lastCursor == undefined)) {
this.lastCursor = this.codeEditor.current.codeMirror.getCursor();
}
if((prevProps.isDragging !== this.props.isDragging) && (!this.props.isDragging)) {
this.codeEditor.current.codeMirror.scrollTo(null, this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true))
this.codeEditor.current.setCursorPosition(this.lastCursor.line, this.lastCursor.ch);
this.lastCursor = undefined;
}
if(this.props.liveScroll) {
if(prevProps.currentBrewRendererPageNum !== this.props.currentBrewRendererPageNum) {
this.sourceJump(this.props.currentBrewRendererPageNum, false);