mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-13 19:32:45 +00:00
Keep the cursor in the active view page after a divider width change.
Solves #2963
This commit is contained in:
@@ -86,7 +86,7 @@ const SplitPane = (props)=>{
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='splitPane' onPointerMove={handleMove} onPointerUp={handleUp}>
|
<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]}
|
{props.children[0]}
|
||||||
</Pane>
|
</Pane>
|
||||||
{renderDivider}
|
{renderDivider}
|
||||||
@@ -102,7 +102,7 @@ const Pane = ({ width, children, isDragging, moveBrew, moveSource, liveScroll, s
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='pane' style={styles}>
|
<div className='pane' style={styles}>
|
||||||
{React.cloneElement(children, { moveBrew, moveSource, liveScroll, setMoveArrows })}
|
{React.cloneElement(children, { moveBrew, moveSource, liveScroll, isDragging, setMoveArrows })}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -100,6 +100,16 @@ const Editor = createClass({
|
|||||||
if(prevProps.moveSource !== this.props.moveSource)
|
if(prevProps.moveSource !== this.props.moveSource)
|
||||||
this.sourceJump();
|
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(this.props.liveScroll) {
|
||||||
if(prevProps.currentBrewRendererPageNum !== this.props.currentBrewRendererPageNum) {
|
if(prevProps.currentBrewRendererPageNum !== this.props.currentBrewRendererPageNum) {
|
||||||
this.sourceJump(this.props.currentBrewRendererPageNum, false);
|
this.sourceJump(this.props.currentBrewRendererPageNum, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user