Unlimited learning, half price | 50% off
Get 50% off unlimited learning

xpectr (version 0.4.4)

navigateTestFileAddin: Navigates to test file

Description

lifecycle::badge("experimental")

RStudio Addin: Extracts file name and (possibly) line number of a test file from a selection or from clipboard content. Navigates to the file and places the cursor at the line number.

Supported types of strings: "test_x.R:3", "test_x.R#3", "test_x.R".

The string must start with "test_" and contain ".R". It is split at either ":" or "#", with the second element (here "3") being interpreted as the line number.

See `Details` for how to set a key command.

Usage

navigateTestFileAddin(selection = NULL, navigate = TRUE, abs_path = TRUE)

Value

Navigates to file and line number.

Does not return anything.

Arguments

selection

String with file name and line number. (Character)

E.g. "test_x.R:3:", which navigates to the third line of "/tests/testthat/test_x.R".

N.B. Mainly intended for testing the addin programmatically.

navigate

Whether to navigate to the file or return the extracted file name and line number. (Logical)

N.B. Mainly intended for testing the addin programmatically.

abs_path

Whether to return the full path or only the file name when `navigate` is FALSE.

N.B. Mainly intended for testing the addin programmatically.

Author

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

Details

How to set up a key command in RStudio

After installing the package. Go to:

Tools >> Addins >> Browse Addins >> Keyboard Shortcuts.

Find "Go To Test File" and press its field under Shortcut.

Press desired key command, e.g. Alt+N.

Press Apply.

Press Execute.

See Also

Other addins: assertCollectionAddin(), dputSelectedAddin(), initializeGXSFunctionAddin(), initializeTestthatAddin(), insertExpectationsAddin(), wrapStringAddin()