function updateSelection() {
  const selectedLine = editor.state.doc.lineAt(
    editor.state.selection.ranges[editor.state.selection.mainIndex].from
  ).number - 1;

  let selectedExpressionIndex;

  processedExpressions.forEach((result, index) => {
    if ((selectedLine >= result.from) && (selectedLine <= result.to)) {
      selectedExpressionIndex = index;
    }
  });

  if (selectedExpressionIndex !== previousSelectedExpressionIndex) {
    const previouslyHighlightedResult = document.querySelector('#result').children[previousSelectedExpressionIndex];
    if (previouslyHighlightedResult !== undefined) {
      previouslyHighlightedResult.className = null;
    }

    const currentlySelectedResult = document.querySelector('#result').children[selectedExpressionIndex];
    if (currentlySelectedResult !== undefined) {
      currentlySelectedResult.className = 'highlighted';
      currentlySelectedResult.scrollIntoView({ block: 'nearest', inline: 'start' });
    }

    previousSelectedExpressionIndex = selectedExpressionIndex;
  }
}
Updates the visual highlighting of results based on the current line selection in the editor.

@function updateSelection
@requires editor, processedExpressions

@description
1. Determines the current line number in the editor's selection.
2. Finds the corresponding result (processed expression) that matches the current line.
3. If a different result is selected than before:
  - Removes highlighting from the previously selected result.
  - Highlights the newly selected result.
  - Scrolls the newly selected result into view.