Giter VIP home page Giter VIP logo

Comments (4)

ericscheid avatar ericscheid commented on September 21, 2024

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.

Gazook89 avatar Gazook89 commented on September 21, 2024

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.

ericscheid avatar ericscheid commented on September 21, 2024

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.

G-Ambatte avatar G-Ambatte commented on September 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.