navigateTestFileAddin {xpectr}R Documentation

Navigates to test file

Description

[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)

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.

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.

Value

Navigates to file and line number.

Does not return anything.

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

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


[Package xpectr version 0.4.3 Index]