Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLOSED] Editor loses position when switching from file to file #5756

Open
core-ai-bot opened this issue Aug 30, 2021 · 15 comments
Open

[CLOSED] Editor loses position when switching from file to file #5756

core-ai-bot opened this issue Aug 30, 2021 · 15 comments

Comments

@core-ai-bot
Copy link
Member

Issue by mikkotikkanen
Friday Dec 27, 2013 at 14:54 GMT
Originally opened as adobe/brackets#6326


Editor loses the current position from time to time and reverts to beginning of the file. Quite a pain with big files.

As a side note, this seems to happen on a setup where Brackets is running on a Windows machine with virtual Ubuntu, which is mounted as a network drive, wherein all the code lives. So, edits happen through the SSH mapped network drive.
Could the editor be using too unspecific data for storing the editor positions? (so outside processes touch the files, it looks like a new file for the editor and the position is lost?)

@core-ai-bot
Copy link
Member Author

Comment by mikkotikkanen
Friday Dec 27, 2013 at 15:27 GMT


Oh, and same thing happens for undo. It seems that most of the time when I change alt+tab to fe. browser and them come back the undo history is gone.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Sunday Dec 29, 2013 at 06:02 GMT


@mikkotikkanen Can you try running Brackets with all extensions disabled and see if these problems still happen then? Also, after you see the problem go to Debug > Show Developer Tools and then look in the Console tab -- any errors logged there?

I do see the scroll position get lost occasionally (jumping back to the top of the file) when switching files, but never simply from Alt+Tabbing in & out of Brackets. And I've never heard of the Undo history disappearing -- that's quite serious. Is the file still marked as "dirty" (unsaved changes -- indicated by a dot/bullet next to the file name), but Undo does nothing? Are you sure the editor still has keyboard focus when you're attempting to undo?

Fwiw, if all you're seeing is the scroll pos getting lost, try tapping the left/right arrows: in the bug I've seen, the cursor position is still correct, so moving the cursor even 1 char will cause the scroll position to jump back down to the correct place.

@core-ai-bot
Copy link
Member Author

Comment by mikkotikkanen
Sunday Dec 29, 2013 at 11:51 GMT


The undo history seem to disappear the same way, alt-tabbing away. Pretty much every time I save and alt-tab to browser.

Although, now that I think of it, I might have a corrupted install (even though I've reinstalled it) as fe. key remappings never seem to stick (they always reset back to normal after exiting brackets). I think I'll do a clean install (uninstall, remove files & folders) and then try things out with vanilla Brackets.

@core-ai-bot
Copy link
Member Author

Comment by mikkotikkanen
Monday Dec 30, 2013 at 10:31 GMT


Ok. I did clean install no Brackets and running with no extensions installed. The undo history just disappeared on me again. Saved, alt-tabbed to browser, refresh, alt-tab back and no undo history.

Another thing that might have something to do with this - For some reason Brackets keeps telling me every now and then that the contents of the file has been changed and do I want to load the latest from disk. No other editor has done this kind of behavior before and I'm quite sure nothing has changed in the file, unless some rogue process in the virtual Ubuntu has done something but it's a clean install, so I doubt it.

Console has one error, though since I didn't check it before I'm not sure if it's related to the issue

[Extension] Error -- could not read native directory: C:/Program Files (x86)/Brackets/www/extensions/dev 

Oh and no, it wasn't "dirty", as I had just saved it. Also, yes, I'm sure the focus was on the editor, was moving the caret around. :)

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Tuesday Dec 31, 2013 at 06:17 GMT


@mikkotikkanen Yes, that's definitely related. As soon as you opt to discard your local changes and reload from disk, the undo history is cleared -- same as doing a 'revert.' (Does your undo history disappear at any time other than when that message appears?) So I think the mystery is really why Brackets keeps seeing the file as externally modified. This should only happen if the timestamp changes after you've saved the file.

Is it possible there's some flaw in your (unusual sounding) SSH-backed VM filesystem setup that could cause file IO operations to report success but only later, after some async delay, begin reflecting that update in read/stat() results? Seems like that sort of race condition would break other apps too, but you never know... that would certainly explain this behavior.

Just to make sure it's not anything specific to your project setup, could you try editing the basic "Getting Started" project that ships with Brackets and see if the same problem occurs there?

Btw, are you running the official Sprint 35 build from download.brackets.io, or some other distro?... or building from git directly?

@core-ai-bot
Copy link
Member Author

Comment by mikkotikkanen
Tuesday Dec 31, 2013 at 08:29 GMT


Yes but I never reload it from the disk, I always use the one I have in the editor. Oh, and the undo history does disappear even without that happening, can happen just with alt-tabbing. I have Eclipse and ConTEXT as a backup editors, and those haven't had the same issue a single time so far, so it's either those having better error handling on that regard or Brackets is doing something differently.

Well, I can try to test that, though as it doesn't happen every time I don't think it's an issue with just random edits on the getting started project. Though, I have other projects that aren't run in Linux environment (meaning, no SSH mounting), so I can report on those later on as I can't remember for sure if it happened with those as well, though I'm thinking yes.

Yeah, official Sprint 35, with clean install and no extensions.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Monday Jan 06, 2014 at 21:11 GMT


@mikkotikkanen Any word on whether this happens with the default Getting Started project, or other projects outside your SSH mounted filesystem?

Also, just to clarify your environment... is this a correct description?

  • The OS you boot into is Windows (what version, btw?)
  • You launch Brackets on Windows
  • You're also running Ubuntu Linux inside a VM
  • Your project files live in the Linux VM's disk image. It's sharing its disk via SSH, and this share is mounted in Windows as a network drive (with a drive letter I assume, not a \\ prefix?).

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Monday Jan 06, 2014 at 22:04 GMT


Two other things we could we could try for diagnostics:

  1. Clone Brackets from git to patch the source code and test a few things out. For example, in Document.notifySaved() you could add a console.log(this.diskTimestamp) at the top of the function and a second console.log(thisDoc.diskTimestamp) at the bottom of the callback, just before the triggerHandler() call. This would tell us whether the filesystem is correctly reporting an updated timestamp after write operations.

  2. Try the file watchers branch (again cloning from git) and comment out the FileSyncManager.syncOpenDocuments() call in brackets.js on that branch. I suspect these changes will make the alt-tab problems go away but you may start seeing a new problem: when you save you'll get a message saying 'the file has been modified on disk, are you sure you want to overwrite it?' If you no longer see problems other than when you save, though, that's useful info because it helps rule out external apps touching the file; it suggests the problem is entirely due to incorrect timestamps being reported by the filesystem.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Monday Jan 06, 2014 at 22:48 GMT


Hmm, interestingly I found the following note in the WriteFile docs:

Note that the time stamps may not be updated correctly for a remote file. To ensure consistent results, use unbuffered I/O.

"Unbuffered I/O" apparently refers to FILE_FLAG_NO_BUFFERING, which sounds very complicated to use correctly.

But then I'm getting conflicting information from other MSDN docs:

File system metadata is always cached. Therefore, to store any metadata changes to disk, the file must either be flushed or be opened with FILE_FLAG_WRITE_THROUGH.

This sounds both scarier on the one hand (implying could get incorrect timestamps on any filesystem, not just remote ones... maybe), and better on the other hand (offering two other solutions that are both simpler than FILE_FLAG_NO_BUFFERING). FlushFileBuffers() sounds reasonably easy to use -- just pass it a file handle. FILE_FLAG_WRITE_THROUGH sounds even simpler to use, and is supposedly faster, but the comments thread on the docs page quoted above has several people saying it doesn't work.

(See more docs about FILE_FLAG_WRITE_THROUGH and FILE_FLAG_NO_BUFFERING here -- especially the "Caching Behavior" section).

@JeffryBooher@redmunds You guys know more about Win APIs than I do... thoughts?

CC@iwehrman &@gruehle too since unreliable timestamps could hose the new filesystem even worse than the old one...

Seems like we might at least want to try setting up a network share and Win machine that can reproduce this behavior, for testing...

@core-ai-bot
Copy link
Member Author

Comment by JeffryBooher
Monday Jan 06, 2014 at 23:05 GMT


We should also test this on a Mac with an SSH share but it may be easier for those without Windows expertise to dive into and debug if we can repro it. (http://www.alirezabagheri.com/blog/?p=67)

I'm not sure how@mikkotikkanen has configured Windows but my guess is that the loopback adapter is what is doing the caching for shares over SSH in this case which is outside of the scope of what the operating system is caching. The notes on MSDN refer to Microsoft Networks (NetBIOS) -- and this setup is an SSH enabled share which sounds like is creating an NTFS junction to manage the communication. Just a guess at this point, though.

@core-ai-bot
Copy link
Member Author

Comment by mikkotikkanen
Tuesday Jan 14, 2014 at 21:52 GMT


Hey. Unfortunately I Haven't had time to properly experiment outside the SSH mount on that computer.

This is the exact environment on that case:

  • Computer itself runs Windows 7
  • Development Ubuntu server runs on Virtualbox
  • Ubuntu is mounted to Windows as network drive (X:) with win-sshfs
  • All project files live inside the Linux box, editing happens through the SSH tunnel on Windows

@core-ai-bot
Copy link
Member Author

Comment by mikkotikkanen
Friday Feb 14, 2014 at 15:43 GMT


Finally had possibility to work with the laptop in question (with the SSH mounts). No issues outside SSH mount, undo history & file position seems to be remembered correctly.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Tuesday Mar 18, 2014 at 05:15 GMT


@mikkotikkanen Have you had a chance to try Brackets Sprint 36 yet? In that version, we significantly changed how external changes are detected. Are you still seeing the problem in that version? If so, are the symptoms any different?

@core-ai-bot
Copy link
Member Author

Comment by mikkotikkanen
Tuesday Mar 18, 2014 at 11:35 GMT


Hey. Unfortunately I'm not running that environment anymore as that project
is done. :/


Mikko Tikkanen
mikko.tikkanen@gmail.com
+358-44 55 11 948

ResponsiveAds
Co-founder
http://responsiveads.com

Zonear Ltd.
Co-founder
http://zonear.com

Mint Usability
http://mintusability.com

2014-03-18 7:15 GMT+02:00 Peter Flynn notifications@github.com:

@mikkotikkanen https://github.com/mikkotikkanen Have you had a chance
to try Brackets Sprint 36 yet? In that version, we significantly changed
how external changes are detected. Are you still seeing the problem in that
version? If so, are the symptoms any different?

Reply to this email directly or view it on GitHubhttps://github.com/adobe/brackets/issues/6326#issuecomment-37900298
.

@core-ai-bot
Copy link
Member Author

Comment by peterflynn
Wednesday Apr 23, 2014 at 00:43 GMT


Closing since there's no way to gather further data and we're unable to reproduce this on our end.

@mikkotikkanen If you start seeing this issue again though, please don't hesitate to reopen or file a new issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant