mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 21:32:42 +00:00
Better line position (viewport has some margin)
This commit is contained in:
@@ -189,7 +189,7 @@ const Editor = createClass({
|
|||||||
if (atCursor)
|
if (atCursor)
|
||||||
lines = lines.slice(0, this.codeEditor.current.getCursorPosition().line + 1); // get cursor page
|
lines = lines.slice(0, this.codeEditor.current.getCursorPosition().line + 1); // get cursor page
|
||||||
else
|
else
|
||||||
lines = lines.slice(0, this.codeEditor.current.getViewport().from + 1); // get view page
|
lines = lines.slice(0, this.codeEditor.current.getTopVisibleLine() + 1); // get view page
|
||||||
|
|
||||||
return _.reduce(lines, (r, line)=>{
|
return _.reduce(lines, (r, line)=>{
|
||||||
if(
|
if(
|
||||||
|
|||||||
@@ -399,8 +399,10 @@ const CodeEditor = createClass({
|
|||||||
getCursorPosition : function(){
|
getCursorPosition : function(){
|
||||||
return this.codeMirror.getCursor();
|
return this.codeMirror.getCursor();
|
||||||
},
|
},
|
||||||
getViewport : function(){
|
getTopVisibleLine : function(){
|
||||||
return this.codeMirror.getViewport();
|
const rect = this.codeMirror.getWrapperElement().getBoundingClientRect();
|
||||||
|
const topVisibleLine = this.codeMirror.lineAtHeight(rect.top, "window");
|
||||||
|
return topVisibleLine;
|
||||||
},
|
},
|
||||||
updateSize : function(){
|
updateSize : function(){
|
||||||
this.codeMirror.refresh();
|
this.codeMirror.refresh();
|
||||||
|
|||||||
Reference in New Issue
Block a user