We've started the official integration of CodeMirror v3 into Brackets. You can get this by pulling the
cmv3 branch from Brackets, then doing
git submodule update, which will switch the CodeMirror2 submodule to use the
upstream-master branch (now that v3 has been officially merged into CodeMirror's master).
We will be submitting various small changes from the
v3-brackets branch into the upstream CodeMirror repo. We are currently tracking these as separate feature branches in our repo. Currently, the feature branches are:
v3-dirty-bit-final-- Already merged upstream. Adds the ability to track a "dirty state" for a document that can be reset with "markClean()". This enables the presentation of a dirty dot in the UI that works appropriately with respect to save, undo, and redo.
General bugs: These are now being tracked in the Brackets issue tracker under the CodeMirror v3 label.
Inline editor bugs:
Stuff to test:
New things we can take advantage of:
The brackets fork of CodeMirror has a bunch of changes that were not integrated into the upstream branch. Most of the changes were dealing with inline widgets, but there were several other small features and performance improvements.
The inline widget changes need to be re-implemented on top of the new line widget API added to CodeMirror 3. A first pass at this has been done in the
nj/cmv3 branch, but it has the issues noted above.
Here are notes on the other changes that were made.
This fixed performance problems when the contents of an inline editor were near the top of a very large file. For example, the
body selector in bootstrap.css. The v3 branch of CodeMirror does not have the same performance problems, so this change doesn't need to be ported.
The v3 branch contains a more comprehensive fix for using document fragments, obviating our changes.
The v3 branch seems to handle this pretty well.
These are no longer necessary with the new inline editor implementation. They were only required because we were injecting dummy nodes into the gutter.
It turns out we didn't need to port this. We've done some testing around our context menus and they seem to work fine without it.
Most of these changes should be trivial to port, as long as Marijn is okay accepting them upstream.
This has already been ported and merged upstream. The API was changed to have
isClean() instead of
We exposed the CodeMirror methods
scrollIntoView() for use in Brackets.
selectWordAt(), we decided to pull the implementation into Brackets since we might want to modify it in future, perhaps in a mode-specific way. This has already been merged into Brackets master (not just cmv3).
scrollIntoView(pos); we'll need to see if we can implement the functionality we need purely using that, or if we need to be able to pass rects as we are today.
We added this function in order to determine how tall an inline editor should be to show all of its content. We might be able to just get this by letting CodeMirror lay itself out and then measuring its height, but I believe there were reasons why that didn't work before. If we can't get that to work, then we'll need to port this, which should be easy.
We will likely need to port these so that CodeMirror doesn't handle things like context menus or double-click in widgets.
This makes it so that when you do Cmd/Ctrl-A to select all, the editor doesn't scroll. This should be easy to port.
If we encounter a
master branch in adobe/CodeMirror2 is completely out of sync with the upstream CodeMirror master, because we actually checked all of our changes directly into our master. In hindsight, that wasn't a good idea :)
For now, since all the v3 work is in a separate branch in the CodeMirror repo, we don't have to worry about our master; we can simply point the submodule SHA in Brackets to the v3 branch. However, once Marijn merges v3 into CodeMirror master, we'll need to bring our master back into sync.
Our proposal is to hard reset our master to the upstream CodeMirror master at that point. Our assumption is that there are no (or very few) people working on the adobe/CodeMirror2 fork, so this shouldn't disrupt anything. Once we've done that, we will never make commits directly to master in our fork; we'll either submit patches directly to Marijn and wait for them to be merged upstream, or we'll create a separate Brackets-specific branch and point our submodule SHA to that branch.
Here's the proposal in more detail:
v3branch from upstream into adobe/CodeMirror2 and keep it in sync with upstream.
brackets-oldbranch based on the current state of our master.
git reset --hard upstream/masterin order to point our master back at upstream. We will never commit directly to our master after this.
bracketsbranch in adobe/CodeMirror to hold this ported functionality, and point the Brackets submodule at that branch.
bracketsbranch as clean as possible, rebasing as necessary to make it so each commit can be submitted directly to CodeMirror upstream as a pull request.
bracketsbranch into CodeMirror upstream, and then just point Brackets at the master branch of adobe/CodeMirror. We'll only revive the separate branch if we need to implement functionality that will take awhile to get accepted upstream, but we'll always try to get it pushed upstream as soon as possible.