Skip to content

Commit

Permalink
Automatically unfold regions when we drive selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Mar 23, 2012
1 parent 802e769 commit 84a2f66
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.PreElement;
import com.google.gwt.dom.client.Style.*;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.GwtEvent;
Expand All @@ -33,7 +32,6 @@
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

import org.rstudio.core.client.ExternalJavaScriptLoader;
import org.rstudio.core.client.ExternalJavaScriptLoader.Callback;
import org.rstudio.core.client.Rectangle;
Expand All @@ -60,7 +58,6 @@
import org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorUtil;
import org.rstudio.studio.client.workbench.views.source.editors.text.ace.*;
import org.rstudio.studio.client.workbench.views.source.editors.text.ace.AceClickEvent.Handler;
import org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position;
import org.rstudio.studio.client.workbench.views.source.editors.text.ace.Renderer.ScreenCoordinates;
import org.rstudio.studio.client.workbench.views.source.editors.text.events.*;
import org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionEvent;
Expand Down Expand Up @@ -824,6 +821,7 @@ public boolean moveSelectionToNextLine(boolean skipBlankLines)
continue;
int col = (match != null) ? match.getIndex() : 0;
getSession().getSelection().moveCursorTo(curRow, col, false);
getSession().unfold(curRow, true);
return true;
}
return false;
Expand All @@ -839,6 +837,7 @@ public boolean moveSelectionToBlankLine()
if (line.length() == 0)
{
getSession().getSelection().moveCursorTo(curRow, 0, false);
getSession().unfold(curRow, true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import org.rstudio.studio.client.workbench.views.source.editors.text.Fold;

import java.util.ArrayList;

public class EditSession extends JavaScriptObject
{
Expand Down Expand Up @@ -126,4 +123,16 @@ public native final JsArray<AceFold> getAllFolds() /*-{
public native final void addFold(String placeholder, Range range) /*-{
this.addFold(placeholder, range);
}-*/;

public native final void unfold(Range range, boolean expandInner) /*-{
this.unfold(range, expandInner);
}-*/;

public native final void unfold(Position pos, boolean expandInner) /*-{
this.unfold(pos, expandInner);
}-*/;

public native final void unfold(int row, boolean expandInner) /*-{
this.unfold(row, expandInner);
}-*/;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public native final Range getRange() /*-{
}-*/;

public native final void setSelectionRange(Range range) /*-{
this.session.unfold(range, true);
this.setSelectionRange(range);
}-*/;

Expand All @@ -35,6 +36,7 @@ public native final Position getCursor() /*-{
public native final void moveCursorTo(int row,
int column,
boolean preventUpdateDesiredColumn) /*-{
this.session.unfold({row: row, column: column}, true);
this.moveCursorTo(row, column, preventUpdateDesiredColumn);
this.setSelectionAnchor(row, column);
}-*/;
Expand Down

0 comments on commit 84a2f66

Please sign in to comment.