Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b1eadb

Browse files
committed
Merge pull request rstudio#150 from rstudio/bugfix/magrittr-pipe-shortcut
Remap magrittr keyboard shortcut
2 parents 00fde16 + 0fb46fb commit 2b1eadb

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

src/gwt/src/org/rstudio/studio/client/workbench/commands/Commands.cmd.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ well as menu structures (for main menu and popup menus).
407407
<shortcut value="Ctrl+Y" title="Insert Yanked Text" />
408408
<shortcut value="Ctrl+T" title="Transpose Letters" if="org.rstudio.core.client.BrowseCap.isMacintosh()"/>
409409
<shortcut value="Alt+-" title="Insert Assignment Operator"/>
410-
<shortcut value="Shift+Alt+." title="Insert Pipe Operator" />
410+
<shortcut value="Cmd+Shift+M" title="Insert Pipe Operator" />
411411
</shortcutgroup>
412412
<shortcutgroup name="Source Navigation">
413413
<shortcut refid="sourceNavigateBack" value="Cmd+F9"/>

src/gwt/src/org/rstudio/studio/client/workbench/views/console/shell/Shell.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import com.google.gwt.event.dom.client.*;
2323
import com.google.gwt.user.client.Command;
2424
import com.google.inject.Inject;
25+
26+
import org.rstudio.core.client.BrowseCap;
2527
import org.rstudio.core.client.CommandWithArg;
2628
import org.rstudio.core.client.StringUtil;
2729
import org.rstudio.core.client.command.CommandBinder;
@@ -531,13 +533,19 @@ else if (mod == KeyboardShortcut.ALT)
531533
break;
532534
}
533535
}
534-
else if (mod == (KeyboardShortcut.ALT + KeyboardShortcut.SHIFT))
536+
else if (
537+
BrowseCap.hasMetaKey() &&
538+
(mod == (KeyboardShortcut.META + KeyboardShortcut.SHIFT)) ||
539+
!BrowseCap.hasMetaKey() &&
540+
(mod == (KeyboardShortcut.CTRL + KeyboardShortcut.SHIFT)))
535541
{
536-
if (keyCode == 190)
542+
switch (keyCode)
537543
{
538-
event.preventDefault();
539-
event.stopPropagation();
540-
input_.replaceSelection(" %>% ", true);
544+
case KeyCodes.KEY_M:
545+
event.preventDefault();
546+
event.stopPropagation();
547+
input_.replaceSelection(" %>% ", true);
548+
break;
541549
}
542550
}
543551
}

src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/TextEditingTarget.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ public void onKeyDown(KeyDownEvent event)
386386
{
387387
NativeEvent ne = event.getNativeEvent();
388388
int mod = KeyboardShortcut.getModifierValue(ne);
389+
389390
if ((mod == KeyboardShortcut.META || (mod == KeyboardShortcut.CTRL && !BrowseCap.hasMetaKey()))
390391
&& ne.getKeyCode() == 'F')
391392
{
@@ -431,9 +432,11 @@ else if ((ne.getKeyCode() == KeyCodes.KEY_ESCAPE) &&
431432
event.stopPropagation();
432433
commands_.interruptR().execute();
433434
}
434-
435-
else if (mod == (KeyboardShortcut.ALT + KeyboardShortcut.SHIFT)
436-
&& ne.getKeyCode() == 190) // period
435+
else if (ne.getKeyCode() == KeyCodes.KEY_M &&
436+
(BrowseCap.hasMetaKey() &&
437+
mod == (KeyboardShortcut.META + KeyboardShortcut.SHIFT)) ||
438+
(!BrowseCap.hasMetaKey() &&
439+
mod == (KeyboardShortcut.CTRL + KeyboardShortcut.SHIFT)))
437440
{
438441
event.preventDefault();
439442
event.stopPropagation();

src/gwt/www/docs/keyboard.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ <h2>Keyboard Shortcuts</h2>
493493
</tr>
494494
<tr>
495495
<td>Insert pipe operator</td>
496-
<td>Shift+Alt+.</td>
497-
<td>Option+Alt+.</td>
496+
<td>Ctrl+Shift+M</td>
497+
<td>Cmd+Shift+M</td>
498498
</tr>
499499
<tr>
500500
<td>Show help for function at cursor</td>

0 commit comments

Comments
 (0)