Comments (4)
They didn't specifically refer to the cursor position though, only the "current position". I would suggest that instead of anchoring on the current cursor position, we anchor on the first visible line.
This way, someone might scroll downwards, see a table that's a bit awkward to read, adjust the editor pane width, and not have the editor viewport reset back to wherever they happened to have left the cursor.
If I want to jump to where I left the cursor I usually just press one of the cursor keys.
from homebrewery.
I can see it both ways.
Let's say I'm editing at full width, and the cursor is in view. I resize the editor and make it narrower. This can send my cursor down 3 or 4 full scrolls depending on the difference full width and new width. It'd be nice to not lose sight of the cursor.
Conversely, like you say, if i'm not necessarily actively making edits/typing, I might just be scrolling through the editor and notice a markdown table that I want to see in full width. Resizing the editor shouldn't jump me back up to the random spot my cursor is at.
I think that you are right: jumping to the random spot your cursor is at in this instance is worse than having to scroll down a few times to a predictable cursor position as in the first example.
Perhaps the best of both worlds (at the expense of computation) is to first determine if the cursor is currently in view in the editor--- if it is, anchor to the cursor position. If it is not, anchor to the first line. Maybe this causes more uncertainty, but maybe it's a small enough difference that it's not jarring.
from homebrewery.
That second case is very similar in effect to the first case. At worst, the first visible line might get scrolled off.
More importantly though .. where would you position the current cursor in the editor viewport? If the wrapping changes such that it would fall below the fold, will you hoist it to be on the last visible line, or the first, or maintain the relative viewport line. The latter would be extra tricky if the brew source line the cursor is within is actually very long and thus might not fully fit within the viewport.
from homebrewery.
determine if the cursor is currently in view
I think what is meant here is "if the cursor is currently in view at the start of the editor resizing process". We'd have to pick up the transition of isDragging
to true
in splitPane.jsx
, capture the current cursor position and first and last visible lines at that time.
If cursor is visible at drag start, then perform cm.scrollIntoView(null)
on completion, which brings to cursor to the visible editor window. If cursors is not visible at drag start, perform cm.scrollIntoView(line)
to move a specific line into view - possibly the visible center of the editor window?
In both cases, the scrollIntoView
function would need to be inserted on line 364 of codeEditor.jsx
, in the updateSize
function. The only real difficulty comes in determining the value of the parameter to pass to that function.
from homebrewery.
Related Issues (20)
- Add brew reset to New Page HOT 5
- Issue with Saving
- Brews removed from Google Drive cannot be deleted from "My Brews" page. HOT 9
- Folding Code Button HOT 6
- Account Name Change HOT 1
- Rework the Class Table generator for better/consistent results HOT 7
- ModHeader breaks the save routine?? HOT 12
- Saving an owned brew while not logged in causes perpetual spinning save icon HOT 4
- Empty elements like `{coverPage}` still take up line space HOT 6
- Add snippet to change column flow HOT 2
- Header 3 fix in monster stat blocks HOT 1
- Default save location resets when AccountPage is refreshed
- Personalisation of User Account HOT 2
- Can't drag text in editor, can't select text in preview
- Cloned brews do not respect Save location setting
- New Page crashes to white screen when not logged in
- FreeBSD installation script fails
- Error Saving HOT 1
- CSS Clean Up HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homebrewery.