Skip to content

Initial Workspace Viewer str() functionality#583

Merged
renkun-ken merged 1 commit intoREditorSupport:masterfrom
danielbasso:workspace-str-functionality
Mar 22, 2021
Merged

Initial Workspace Viewer str() functionality#583
renkun-ken merged 1 commit intoREditorSupport:masterfrom
danielbasso:workspace-str-functionality

Conversation

@danielbasso
Copy link
Copy Markdown
Contributor

@danielbasso danielbasso commented Mar 18, 2021

What problem did you solve?

As stated in #577, the current workspace viewer displays a list of globalEnv objects without further detail. For lists and dataframes, would be nice to see a sub-list of its elements, like the function str() output. I've implemented this functionality taking advantage of the already implemented .Rprofile option for src()-like output on hover, vsc.str.max.level = 0 | 1 | 2

Screenshot

Take for example this code:

library(tidyverse)

my_list  <-  list(a = function(x) x, y = " small string", z = c(1, 2, 3))

my_tibble  <- tibble(x = c(1,2,4,5,5,5,5,5,5,5), 
                  y = c(2,2,2,2,2,2,2,7,8,9), 
                  z = rep("aaa\n", 10),
                  shrnm = rnorm(10),
                  really_long_variable_name = rnorm(10))                  

my_number  <-  123

my_string  <-  "lala \n lala"

vsc.str.max.level = 2

image

vsc.str.max.level = 1

image

vsc.str.max.level = 0 (as before)

image

As far as I tested, it is robust to line breaks (\n); it won't show any tooltip or View/Remove buttons for the subitens (harder to implement that I expected); It will only show expandable icons (>) for objects of list type:
image

Known issue: as it uses the same option for str() display on object hover, you can't set one option apart from the other. I decided to let it this way mainly because two reasons:

  1. The option name vsc.str.max.level is generic enough to allow this and;

  2. It would have required extra work to implement another option just for this, risking breaking something that is already working. I can't think of any concrete example of someone that would lika an complete str() on hover and none in the workspace, or vice-versa. Seemed to me an extra work for little return.

@danielbasso danielbasso changed the title Initial Workspace Viewer str() functionality (#577) Initial Workspace Viewer str() functionality Mar 18, 2021
Copy link
Copy Markdown
Member

@renkun-ken renkun-ken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Tested on macOS and Ubuntu and it works nicely.

@danielbasso
Copy link
Copy Markdown
Contributor Author

Not related at all with the PR, but i don't know where to ask: could you guys enable the 'Discussion Tab' for this project? I have some questions about the project inner workings that I would like to clarify, but the only way to communicate right now is through issues, which IMO is not ideal since issues should be specific for bugs or feature requests.

@renkun-ken
Copy link
Copy Markdown
Member

I agree that we could enable the discussion. We need @Ikuyadeu to proceed in the project settings.

@Ikuyadeu
Copy link
Copy Markdown
Member

@danielbasso @renkun-ken OK, now I opened Discussion.
https://github.com/Ikuyadeu/vscode-R/discussions

@renkun-ken renkun-ken merged commit ba7c136 into REditorSupport:master Mar 22, 2021
@danielbasso danielbasso deleted the workspace-str-functionality branch March 22, 2021 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants