Skip to content

Commit

Permalink
finishing up for multi code blocs
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelb committed Apr 13, 2022
1 parent 512a0d0 commit c9ead0c
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 76 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.2
- Run multiple code blocs at one in markup languages
- Fix multiline display for nvim-notify

## v1.2.1
- F# support
- Fix multiline display in floating windows
Expand Down
106 changes: 73 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sniprun"
version = "1.2.1"
version = "1.2.2"
authors = ["michaelb <[email protected]>"]
edition = "2018"

Expand Down
3 changes: 3 additions & 0 deletions ressources/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ require'sniprun'.setup({
})
```
![](visual_assets/api.png)


Changing the contents of the buffer will generally not interfere with sniprun with the exception of running multiple code blocs in a markup language (such as markdown or orgmode), because sniprun gets the list of the positions of the code blocs once, before running & displaying once per code bloc
23 changes: 9 additions & 14 deletions src/interpreters/GFM_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,23 @@ impl GFM_original {
let selection_line = self.data.range[0] as usize;
let mut v = vec![];
for (i,l) in lines.iter().enumerate() {
info!("checking code bloc delimiter in : {l}");
if (l.trim_start().starts_with("```") && !l.trim_start()[3..].trim().is_empty())
&& counter % 2 == 1
{
return Err(SniprunError::CustomError(String::from(
"Partially selected code bloc",
)));
}

if l.trim_start().starts_with("```") {
counter += 1;
if counter % 2 == 1 {
info!("here3");
v.push((selection_line + i + 1, 0));
} else {
info!("here4: v is {v:?}");
v[((counter - 1) / 2) as usize].1 = selection_line + i - 1;
info!("here4done");
}
}
if (l.trim_start().starts_with("```") && !l.trim_start()[3..].trim().is_empty())
&& counter % 2 == 1
{
info!("here2");
return Err(SniprunError::CustomError(String::from(
"Partially selected code bloc",
)));
}
}
info!("here4");
}
if counter >= 2 {
info!("counting {counter} code blocs delimiters");
if counter % 2 == 1 {
Expand Down
Loading

0 comments on commit c9ead0c

Please sign in to comment.