Search in sources :

Example 1 with LineHandle

use of net.codemirror.lib.CodeMirror.LineHandle in project gerrit by GerritCodeReview.

the class SideBySide method updateActiveLine.

@Override
Runnable updateActiveLine(CodeMirror cm) {
    CodeMirror other = otherCm(cm);
    return () -> {
        // The rendering of active lines has to be deferred. Reflow
        // caused by adding and removing styles chokes Firefox when arrow
        // key (or j/k) is held down. Performance on Chrome is fine
        // without the deferral.
        //
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                operation(() -> {
                    LineHandle handle = cm.getLineHandleVisualStart(cm.getCursor("end").line());
                    if (!cm.extras().activeLine(handle)) {
                        return;
                    }
                    LineOnOtherInfo info = lineOnOther(cm.side(), cm.getLineNumber(handle));
                    if (info.isAligned()) {
                        other.extras().activeLine(other.getLineHandle(info.getLine()));
                    } else {
                        other.extras().clearActiveLine();
                    }
                });
            }
        });
    };
}
Also used : LineHandle(net.codemirror.lib.CodeMirror.LineHandle) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) LineOnOtherInfo(com.google.gerrit.client.diff.LineMapper.LineOnOtherInfo) CodeMirror(net.codemirror.lib.CodeMirror)

Aggregations

LineOnOtherInfo (com.google.gerrit.client.diff.LineMapper.LineOnOtherInfo)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 CodeMirror (net.codemirror.lib.CodeMirror)1 LineHandle (net.codemirror.lib.CodeMirror.LineHandle)1