Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve token completion #372

Merged
merged 4 commits into from
Jan 28, 2021

Conversation

renkun-ken
Copy link
Member

@renkun-ken renkun-ken commented Jan 27, 2021

This PR improves the token completion with the following changes:

  1. Since Add '(' to completion trigger characters #369 allows ( to trigger completion to in accompany with Add initial pipeline completion support vscode-R#530, the current token_completion may produce too many symbols once ( triggers completion. This PR makes token_completion only show symbols after $ and SYMBOL_SUB symbols like foo in mutate(foo = bar) when trigger token is empty (e.g. foo$ and fun(), which are the most frequent ways to introduce new data variables.
  2. If token is not empty, then all symbols from the document that start with token are searched, which is the original method.

This makes it possible to work with the following examples:

library(data.table)
library(dplyr)
library(tibble)

tbl1 <- tibble(
  Name = c("Product1", "Product2", "Product3"),
  Quality = c("Good", "Good", "Best"),
  Score = c(8, 9, 10),
  Type = c("B", "B", "A")
)

tbl1 %>%
  mutate(Score_mean = mean(Score)) %>%
  select(|

x <- iris
x %>%
  mutate(score1 = Petal.Length + Petal.Width, score2 = Petal.Length * Petal.Width) %>%
  filter(|


df <- list(
  test1 = 1,
  test2 = 2
)
df$test3 <- 3
df$te|


dt <- data.table(var1 = 1:10, var2 = rnorm(10))
dt[, var3 := var1 + var2]
dt[, var4 := var|]

where | is the cursor and the completion should work as expected to complete the tokens from the document.

Copy link
Member

@randy3k randy3k left a comment

Choose a reason for hiding this comment

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

Perfect.

@renkun-ken renkun-ken merged commit 2c32169 into REditorSupport:master Jan 28, 2021
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.

None yet

2 participants