From 4aadb0b23821989b211e6a3ca157c943f809b499 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 30 Jul 2025 12:28:06 -0500 Subject: [PATCH 1/5] Keep the cursor in the active view page after a divider width change. Solves #2963 --- client/components/splitPane/splitPane.jsx | 4 ++-- client/homebrew/editor/editor.jsx | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/components/splitPane/splitPane.jsx b/client/components/splitPane/splitPane.jsx index 4c77d81a5..4e100638f 100644 --- a/client/components/splitPane/splitPane.jsx +++ b/client/components/splitPane/splitPane.jsx @@ -86,7 +86,7 @@ const SplitPane = (props)=>{ return (
- + {props.children[0]} {renderDivider} @@ -102,7 +102,7 @@ const Pane = ({ width, children, isDragging, moveBrew, moveSource, liveScroll, s return (
- {React.cloneElement(children, { moveBrew, moveSource, liveScroll, setMoveArrows })} + {React.cloneElement(children, { moveBrew, moveSource, liveScroll, isDragging, setMoveArrows })}
); }; diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 8d331e46e..4a7b9be08 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -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); From 785af639c7c3e29787d268e9e3d1064d6d50bffb Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 30 Jul 2025 13:04:16 -0500 Subject: [PATCH 2/5] Keep the cursor as close to the same place on the screen as possible. --- client/homebrew/editor/editor.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 4a7b9be08..4894b881d 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -102,10 +102,15 @@ const Editor = createClass({ if((prevProps.isDragging !== this.props.isDragging) && (this.props.isDragging) && (this.lastCursor == undefined)) { this.lastCursor = this.codeEditor.current.codeMirror.getCursor(); + const lastXY = this.codeEditor.current.codeMirror.getScrollInfo(); + const lastRowPos = this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true); + this.lastCursor.offset = Math.round(lastRowPos-lastXY.top); } 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)) + const scroll = this.codeEditor.current.codeMirror.getScrollInfo(); + this.codeEditor.current.codeMirror.scrollTo(null, + this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true) - this.lastCursor.offset); this.codeEditor.current.setCursorPosition(this.lastCursor.line, this.lastCursor.ch); this.lastCursor = undefined; } From 460b12e3569476b959022411cf0b508228e0f1b9 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 5 Oct 2025 11:26:43 -0500 Subject: [PATCH 3/5] Proposed fix per calc. This also works but has different currsor behavior. Original fix left in place, commented pending decisions. --- client/homebrew/editor/editor.jsx | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 4a4dff0f3..dd810f33a 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -97,20 +97,20 @@ 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(); - const lastXY = this.codeEditor.current.codeMirror.getScrollInfo(); - const lastRowPos = this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true); - this.lastCursor.offset = Math.round(lastRowPos-lastXY.top); - } + // if((prevProps.isDragging !== this.props.isDragging) && (this.props.isDragging) && (this.lastCursor == undefined)) { + // this.lastCursor = this.codeEditor.current.codeMirror.getCursor(); + // const lastXY = this.codeEditor.current.codeMirror.getScrollInfo(); + // const lastRowPos = this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true); + // this.lastCursor.offset = Math.round(lastRowPos-lastXY.top); + // } - if((prevProps.isDragging !== this.props.isDragging) && (!this.props.isDragging)) { - const scroll = this.codeEditor.current.codeMirror.getScrollInfo(); - this.codeEditor.current.codeMirror.scrollTo(null, - this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true) - this.lastCursor.offset); - this.codeEditor.current.setCursorPosition(this.lastCursor.line, this.lastCursor.ch); - this.lastCursor = undefined; - } + // if((prevProps.isDragging !== this.props.isDragging) && (!this.props.isDragging)) { + // const scroll = this.codeEditor.current.codeMirror.getScrollInfo(); + // this.codeEditor.current.codeMirror.scrollTo(null, + // this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true) - this.lastCursor.offset); + // this.codeEditor.current.setCursorPosition(this.lastCursor.line, this.lastCursor.ch); + // this.lastCursor = undefined; + // } if(this.props.liveScroll) { if(prevProps.currentBrewRendererPageNum !== this.props.currentBrewRendererPageNum) { @@ -424,7 +424,6 @@ const Editor = createClass({ //Called when there are changes to the editor's dimensions update : function(){ - this.codeEditor.current?.updateSize(); const snipHeight = document.querySelector('.editor > .snippetBar').offsetHeight; if(snipHeight !== this.state.snippetbarHeight) this.setState({ snippetbarHeight: snipHeight }); From 8fcadd87d47cce556c96e6e31000f4cbae1a5915 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 9 Oct 2025 20:24:01 -0500 Subject: [PATCH 4/5] Remove comments --- client/homebrew/editor/editor.jsx | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index dd810f33a..033b04557 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -97,21 +97,6 @@ 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(); - // const lastXY = this.codeEditor.current.codeMirror.getScrollInfo(); - // const lastRowPos = this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true); - // this.lastCursor.offset = Math.round(lastRowPos-lastXY.top); - // } - - // if((prevProps.isDragging !== this.props.isDragging) && (!this.props.isDragging)) { - // const scroll = this.codeEditor.current.codeMirror.getScrollInfo(); - // this.codeEditor.current.codeMirror.scrollTo(null, - // this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true) - this.lastCursor.offset); - // 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); @@ -155,7 +140,7 @@ const Editor = createClass({ handleViewChange : function(newView){ this.props.setMoveArrows(newView === 'text'); - + this.setState({ view : newView }, ()=>{ From fbf0d425e2c5f3a7824f7154cd0daf1afed40bf7 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 11 Oct 2025 09:07:23 -0500 Subject: [PATCH 5/5] Don't pass isDragging to splitpane children. --- client/components/splitPane/splitPane.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/components/splitPane/splitPane.jsx b/client/components/splitPane/splitPane.jsx index 4e100638f..4c77d81a5 100644 --- a/client/components/splitPane/splitPane.jsx +++ b/client/components/splitPane/splitPane.jsx @@ -86,7 +86,7 @@ const SplitPane = (props)=>{ return (
- + {props.children[0]} {renderDivider} @@ -102,7 +102,7 @@ const Pane = ({ width, children, isDragging, moveBrew, moveSource, liveScroll, s return (
- {React.cloneElement(children, { moveBrew, moveSource, liveScroll, isDragging, setMoveArrows })} + {React.cloneElement(children, { moveBrew, moveSource, liveScroll, setMoveArrows })}
); };