@@ -122,14 +122,14 @@ file_outline <- function(pattern = NULL,
122
122
file_content <- rlang :: set_names(path )
123
123
# Not warn
124
124
file_content <- purrr :: map(file_content , function (x ) readLines(fs :: path_real(x ), encoding = " UTF-8" , warn = FALSE ))
125
- # Combine everything into a tibble that contains file, line_id , content
126
- file_content <- purrr :: map(file_content , function (x ) tibble :: enframe(x , name = " line_id " , value = " content" ))
125
+ # Combine everything into a tibble that contains file, line , content
126
+ file_content <- purrr :: map(file_content , function (x ) tibble :: enframe(x , name = " line " , value = " content" ))
127
127
file_content <- dplyr :: bind_rows(file_content , .id = " file" )
128
128
} else {
129
129
file_content <-
130
130
purrr :: map(
131
131
.x = list (" unsaved-doc.R" = rstudioapi :: getSourceEditorContext()$ contents ),
132
- .f = function (x ) tibble :: enframe(x , name = " line_id " , value = " content" )
132
+ .f = function (x ) tibble :: enframe(x , name = " line " , value = " content" )
133
133
)
134
134
file_content <- dplyr :: bind_rows(file_content , .id = " file" )
135
135
}
@@ -365,7 +365,7 @@ print.outline_report <- function(x, ...) {
365
365
link = list (rlang :: set_names(
366
366
link_rs_api ,
367
367
purrr :: map_chr(
368
- paste0(" {.file " , file , " :" , line_id , " }" ),
368
+ paste0(" {.file " , file , " :" , line , " }" ),
369
369
cli :: format_inline
370
370
)
371
371
)),
@@ -507,19 +507,19 @@ display_outline_element <- function(.data) {
507
507
y <- dplyr :: mutate(
508
508
x ,
509
509
has_title_el =
510
- ((line_id == 1 & ! is_todo_fixme & ! is_test_name & ! is_snap_file ) |
510
+ ((line == 1 & ! is_todo_fixme & ! is_test_name & ! is_snap_file ) |
511
511
(is_doc_title & ! is_subtitle & ! is_snap_file & ! is_second_level_heading_or_more )) & ! is_news ,
512
512
.by = " file"
513
513
)
514
514
y <- withCallingHandlers(
515
515
dplyr :: mutate(y ,
516
- title_el_line = ifelse(has_title_el , line_id [
517
- (line_id == 1 & ! is_todo_fixme & ! is_test_name & ! is_snap_file ) |
516
+ title_el_line = ifelse(has_title_el , line [
517
+ (line == 1 & ! is_todo_fixme & ! is_test_name & ! is_snap_file ) |
518
518
(is_doc_title & ! is_subtitle & ! is_snap_file & ! is_second_level_heading_or_more )
519
519
][1 ], # take the first element to avoid problems (may be the reason why problems occur)
520
520
NA_integer_
521
521
),
522
- title_el = outline_el [line_id == title_el_line ],
522
+ title_el = outline_el [line == title_el_line ],
523
523
.by = " file"
524
524
),
525
525
error = function (e ) {
@@ -529,7 +529,7 @@ display_outline_element <- function(.data) {
529
529
)
530
530
y <- dplyr :: relocate(
531
531
y ,
532
- " outline_el" , " line_id " , " title_el" , " title_el_line" , " has_title_el" ,
532
+ " outline_el" , " line " , " title_el" , " title_el_line" , " has_title_el" ,
533
533
.after = " content"
534
534
)
535
535
@@ -595,7 +595,7 @@ construct_outline_link <- function(.data, is_saved_doc, dir_common, pattern) {
595
595
as.character(trim_outline(.data $ outline_el [cn ], width - 8L )),
596
596
" - {.run [Done{cli::symbol$tick}?](reuseme::complete_todo(" ,
597
597
# Removed ending dot. (possibly will fail with older versions)
598
- .data $ line_id [cn ], " , '" , .data $ file [cn ], " ', '" ,
598
+ .data $ line [cn ], " , '" , .data $ file [cn ], " ', '" ,
599
599
# modify regex twice if needed (see below)
600
600
stringr :: str_sub(stringr :: str_replace_all(.data $ content [cn ], " \\ ^|\\ $|'|\\ {|\\ }|\\ )|\\ (|\\ [\\ ]|\\ +" , " ." ), start = - 15L ), " '))}" ,
601
601
.data $ rs_version [cn ]
@@ -617,7 +617,7 @@ construct_outline_link <- function(.data, is_saved_doc, dir_common, pattern) {
617
617
# Removed ending dot. (possibly will fail with older versions)
618
618
619
619
# modify regex twice if needed (see above)
620
- line_id , " , '" , file , " ', '" , stringr :: str_sub(stringr :: str_replace_all(content , " \\ ^|\\ $|'|\\ {|\\ }|\\ )|\\ (|\\ [\\ ]|\\ +" , " ." ), start = - 15L ), " '))}" ,
620
+ line , " , '" , file , " ', '" , stringr :: str_sub(stringr :: str_replace_all(content , " \\ ^|\\ $|'|\\ {|\\ }|\\ )|\\ (|\\ [\\ ]|\\ +" , " ." ), start = - 15L ), " '))}" ,
621
621
rs_version
622
622
),
623
623
outline_el2
@@ -626,7 +626,7 @@ construct_outline_link <- function(.data, is_saved_doc, dir_common, pattern) {
626
626
)
627
627
628
628
.data <- dplyr :: mutate(.data ,
629
- link = paste0(outline_el2 , " {.path " , file , " :" , line_id , " }" ),
629
+ link = paste0(outline_el2 , " {.path " , file , " :" , line , " }" ),
630
630
# rstudioapi::documentOpen works in the visual mode!! but not fully.
631
631
file_path = .data $ file ,
632
632
is_saved_doc = .env $ is_saved_doc ,
@@ -646,15 +646,15 @@ construct_outline_link <- function(.data, is_saved_doc, dir_common, pattern) {
646
646
}
647
647
648
648
dplyr :: mutate(.data ,
649
- # link_rs_api = paste0("{.run [", outline_el, "](reuseme::open_rs_doc('", file_path, "', line = ", line_id , "))}"),
649
+ # link_rs_api = paste0("{.run [", outline_el, "](reuseme::open_rs_doc('", file_path, "', line = ", line , "))}"),
650
650
link_rs_api = dplyr :: case_when(
651
651
is.na(outline_el2 ) ~ NA_character_ ,
652
- ! is_saved_doc ~ paste0(" line " , line_id , " -" , outline_el2 ),
652
+ ! is_saved_doc ~ paste0(" line " , line , " -" , outline_el2 ),
653
653
rs_avail_file_link ~ paste0(
654
654
" {cli::style_hyperlink(" , style_fun , ' , "' ,
655
- paste0(" file://" , file_path ), ' ", params = list(line = ' , line_id , " , col = 1))} " , outline_el2
655
+ paste0(" file://" , file_path ), ' ", params = list(line = ' , line , " , col = 1))} " , outline_el2
656
656
),
657
- .default = paste0(rs_version , " {.run [i](reuseme::open_rs_doc('" , file_path , " ', line = " , line_id , " ))} " , outline_el2 )
657
+ .default = paste0(rs_version , " {.run [i](reuseme::open_rs_doc('" , file_path , " ', line = " , line , " ))} " , outline_el2 )
658
658
),
659
659
file_hl = dplyr :: case_when(
660
660
! is_saved_doc ~ file_path ,
0 commit comments