Repository: denisidoro/navi
File: src/parser.rs (Rust)

Code before:
        lines: impl Iterator<Item = Result<String>>,
        id: &str,
        file_index: Option<usize>,
    ) -> Result<()> {
        let mut item = Item::new(file_index);

        let mut should_break = false;

        let mut variable_cmd = String::from("");

        let mut inside_snippet: bool = false;

        for (line_nr, line_result) in lines.enumerate() {
            let line = line_result
                .with_context(|| format!("Failed to read line number {line_nr} in cheatsheet `{id}`"))?;

            if should_break {
                break;
            }

            // duplicate
            // if !item.tags.is_empty() && !item.comment.is_empty() {}

            // blank
            if line.is_empty() {
                if !item.snippet.is_empty() && inside_snippet {
                    item.snippet.push_str(deser::LINE_SEPARATOR);
                }
            }
            // tag
            else if line.starts_with('%') {
                should_break = self.write_cmd(&item).is_err();
                item.snippet = String::from("");
                item.tags = without_prefix(&line);
            }
            // dependency
            else if line.starts_with('@') {
                let tags_dependency = without_prefix(&line);
                self.variables.insert_dependency(&item.tags, &tags_dependency);
            }
            // raycast icon
            else if let Some(icon) = line.strip_prefix("; raycast.icon:") {
                item.icon = Some(icon.trim().into());
            }
            // metacomment
            else if line.starts_with(';') {
            }
            // comment
            else if line.starts_with('#') {
                // if current item has a snippet, write it to the finder and start a new item
                if !item.snippet.is_empty() {

Review comment (suggestion):
This change is unrelated to multiline descriptions.
And this breaks some snippets.
Example:
```sh
echo "The next line is empty.

The previous line is empty."
```

Code after:
        lines: impl Iterator<Item = Result<String>>,
        id: &str,
        file_index: Option<usize>,
    ) -> Result<()> {
        let mut item = Item::new(file_index);

        let mut should_break = false;

        let mut variable_cmd = String::from("");

        let mut inside_snippet: bool = false;

        for (line_nr, line_result) in lines.enumerate() {
            let line = line_result
                .with_context(|| format!("Failed to read line number {line_nr} in cheatsheet `{id}`"))?;

            if should_break {
                break;
            }

            // duplicate
            // if !item.tags.is_empty() && !item.comment.is_empty() {}

            // blank
            if line.is_empty() {
                if !item.snippet.is_empty() {
                    item.snippet.push_str(deser::LINE_SEPARATOR);
                }
            }
            // tag
            else if line.starts_with('%') {
                should_break = self.write_cmd(&item).is_err();
                item.snippet = String::from("");
                item.comment = String::from("");
                item.tags = without_prefix(&line);
            }
            // dependency
            else if line.starts_with('@') {
                let tags_dependency = without_prefix(&line);
                self.variables.insert_dependency(&item.tags, &tags_dependency);
            }
            // raycast icon
            else if let Some(icon) = line.strip_prefix("; raycast.icon:") {
                item.icon = Some(icon.trim().into());
            }
            // metacomment
            else if line.starts_with(';') {
            }
            // comment
            else if line.starts_with('#') {
                // if current item has a snippet, write it to the finder and start a new item