adobe / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
33.25k stars 7.63k forks source link

Undo scrolls document to the top #11113

Open tciuro opened 9 years ago

tciuro commented 9 years ago

Hello,

When I undo some text, I oftentimes end up at the top of the document, that is, it seems like Undo is losing track of the current scrollbar position. The weird thing is that if I continue selecting Undo, I eventually end up in the right location, but the problem is that I've undo'ed more than I should.

rroshan1 commented 9 years ago

@tciuro I am unable to reproduce the issue. Please share the OS and version of Brackets you are using. It would be great if you could share some gif to give more insight into the issue.

tciuro commented 9 years ago

@rroshan1 ah, I see what's happening. When it does the undo, the top-most line shows the line where it's going to perform the undo action. I'm used to see the line that's about to be undone somewhere in the middle of the screen where it's more visible/obvious.

I wonder if it would be possible to do that, or perhaps even briefly flash the line. Some themes (especially darker ones like Mbo) have poor contrasted highlight, which added to the not-so-obvious scroll to the affected line, makes it confusing. Do I make sense?

craigvl commented 9 years ago

Yes this issue drives me nuts trying to find the line that the undo or redo is working on.

chrisnovello commented 9 years ago

Getting this same issue on 1.4.0-16380 — undo bounces me to the top of the document all the time. Very jarring / breaks flow

abose commented 9 years ago

After this happens, can you go to debug>show developer tools>console and paste the console logs here?

chrisnovello commented 9 years ago

Will do. So far I think I've only seen this with CSS files btw

tciuro commented 9 years ago

I see that all the time with JS files. I'm very surprised that some of you don't see it. Perhaps Brackets conflicts with some of the modules? This is what I see in console:

/thirdparty/react.js:4486 Download the React DevTools for a better development experience: http://fb.me/react-devtools
/utils/DeprecationWarning.js:90 PreferencesManager.convertPreferences() has been deprecated. Please upgrade to the current Preferences system (https://github.com/adobe/brackets/wiki/Preferences-System#conversion-from-the-pre-36-preferences-system).
    at Object.convertPreferences (/preferences/PreferencesManager.js:325:28)
    at Object.eval (/utils/Resizer.js:548:24)
/utils/DeprecationWarning.js:90 Deprecated: Do not use $().on/off() on Brackets modules and model objects. Call on()/off() directly on the object without a $() wrapper.
    at new jQuery.fn.init (/brackets.js:474:36)
    at n (file:///Applications/Brackets.app/Contents/www/thirdparty/thirdparty.min.js:559:405)
/LiveDevelopment/MultiBrowserImpl/transports/NodeSocketTransport.js:87 NodeSocketTransport - start
file:///Users/tito/Library/Application%20Support/Brackets/extensions/user/interactive-linter/libs/js/spromise.min.js.map Failed to load resource: net::ERR_FILE_NOT_FOUND

The list of modules I have:

Beautify
 Brackets File tabs
 Brackets Git
 Brackets Icons
 Code Outline
 Interactive Linter
 JSHint
 Themes for Brackets
abose commented 9 years ago

@paperkettle could you list the extensions you have installed in brackets. @tciuro could you go to debug>reload without extensions and see if the issue is reproducible?

designcise commented 8 years ago

I witnessed this issue on Release 1.8 build 1.8.0-17080, after saving by hitting CTRL+S and then trying to undo, which doesn't work in such instance, but rather scrolls to the top.

zaggino commented 8 years ago

@designcise have you also tried reloading without extensions?

designcise commented 8 years ago

@zaggino I didn't, I closed brackets and just restarted it again which solved it for time being. If I witness this again, I'll try reloading it without extensions. I don't know exactly how to reproduce this, but my guess is if I reload it without extensions, the issue would go away in any case (like it did when I restarted Brackets). So not, sure if it would yield any useful information in this instance.

designcise commented 8 years ago

Witnessed it about 3 times yesterday, again with CTRL+S while working. This makes the document scroll to top (to a random location) and messes up the undo. Tried reproducing it, wasn't able to pinpoint the problem.

zaggino commented 8 years ago

@designcise this is almost certainly caused by an external modification of the file. Is there anything (extension or a gulp watch task in background) that'd modify file after saving it? It actually doesn't scroll top to a random location, but to a location of the first change.

For example if you'd have an extension that'd strip whitespace from the file, it'd scroll top to the first line with whitespace stripped.

designcise commented 8 years ago

@zaggino The only two extensions I'm using are:

  1. Console
  2. Open a new editor window

There's nothing else externally modifying the file as it is only open in brackets.

designcise commented 8 years ago

Witnessed it thrice more just now, I was able to observe the behavior this time; the mouse cursor repositions to the curly brace after the function name I was working inside of, and the document scrolls to the start of one function before it.

zaggino commented 8 years ago

If you use brackets beautify (https://github.com/brackets-beautify/brackets-beautify#usage) you should try turning Beautify on Save feature off. Any other extensions which do things after save can possibly be causing this issue too.

designcise commented 8 years ago

So I was finally able to figure out what's going on. Upon saving, collapsed code-folds automatically expand which is why it appears that the document scrolled to the top. This behavior also disables undo!

zaggino commented 8 years ago

@thehogfather ? is that possible ?

thehogfather commented 8 years ago

This is possible if the document is modified in a different editor or in source control - and the original folded region becomes invalid. In that scenario, the intended behaviour would be to expand the invalid fold states. Another scenario would probably be a bug. @designcise If you can consistently reproduce this, please enumerate the steps required to reproduce and I will take a look.

designcise commented 8 years ago

@thehogfather the file is not edited in a different editor. I was able to reproduce it several times like so (but only for files with extensions '.js' -- although i've witnessed this behavior in other file types too):

You will then see folded code panes expand, and also lose the ability to undo. And for some reason, once this happens, every time you save, the folded code panes will unfold no matter what.

zaggino commented 8 years ago

@designcise 1) can you share the project with us on github? 2) can you provide your health report? (help -> health report)

designcise commented 8 years ago

Help Report:

{ "uuid": "769518fa-bf57-4376-9cee-4726d9f7109f", "snapshotTime": 1476830688523, "os": "win", "userAgent": "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Brackets/1.8.0.0 Chrome/49.0.2623.110 Safari/537.36", "osLanguage": "en-US", "bracketsLanguage": "en-US", "bracketsVersion": "1.8.0-17080", "fileStats": { "openedFileExt": { "php": 10, "js": 14, "json": 1, "tpl": 1 }, "workingSetFileExt": { "json": 1, "php": 3, "js": 4 } }, "projectLoadTimes": "", "fileOpenTimes": ":100:67(79)88[6]:72(79)88[7]:120:184(236)335[70]:127:79:444:1688:216:80:24:56", "prefNodeSearchDisabled": false, "prefInstantSearchDisabled": false, "installedExtensions": [ { "name": "new-window", "version": "0.0.1" }, { "name": "brackets-console", "version": "1.4.1" } ], "bracketsTheme": "dark-theme" }

I won't be able to share the project because it's 2365 files big and because of its commercial nature. I can, however, provide some more insight:

  1. I tried downloading the same javascript from the internet that i was having a problem with, and opened it in brackets (whilst in the same project), and there was no problem when I applied the steps I mentioned.
  2. When I copied that downloaded file over to my project's folder and then tried repeating the steps, I encountered the problem.
  3. Then I tried editing that downloaded file by browsing to its folder and making a new project in brackets, tried repeating the steps and had no problem.
  4. Also, after re-opening the project I was working on, and editing the files again and repeating the steps, I didn't encounter the problem.

It would seem that this happens with big projects; when you're working on them for some time. Somewhere some file that saves code folding data might be getting corrupted or something.

elifares commented 7 years ago

I am having this issue too. Clicking undo scrolls the document to the top/random section of my HTML file.

RYJASM commented 6 years ago

Any updates on this? This drives me nuts. It's been there since the beginning. I'm so used to pressing ctrl+a and then shift tab to perform auto indention and everytime I do and have to hit undo the document scrolls to the top (no extensions installed at all). Let's remove the "scroll to the first line of the undo" if there is an action performed on all content.

elifares commented 6 years ago

Here's my update: I stopped using Brackets and switched to Atom.

xypd commented 4 years ago

This issue was happening to me recently. This thread didn't really provide much confidence that extensions were the issues.

However It seems (only just made this change) to have been related to an extension for me. I disable https://github.com/pelatx/brackets-link-file and the problem seems to have stopped.

This was after seeing it stop after reload with ext off, solved my issue.