Skip to content

Conversation

@schneems
Copy link
Collaborator

@schneems schneems commented Apr 14, 2023

I previously left a comment stating I didn't know why a certain method existed. In investigating the code in CaptureCodeContext#capture_before_after_kws I found that it was added as to give a slightly less noisy output.

The docs for AroundBlockScan#capture_neighbor_context only describe keywords as being a primary concern. I modified that code to only include lines that are keywords or ends. This reduces the output noise even more.

This allows me to remove that start_at_next_line method.

One weird side effect of the prior logic is it would cause this code to produce this output:

        class OH
          def hello

          def hai
          end
        end
          1  class OH
        > 2    def hello
          4    def hai
          5    end
          6  end

But this code to produce this output:

        class OH
          def hello
          def hai
          end
        end
          1  class OH
        > 2    def hello
          4    end
          5  end

Note the missing def hai. The only difference between them is that space.

With this change, they're now both consistent.

I previously left a comment stating I didn't know why a certain method existed. In investigating the code in `CaptureCodeContext#capture_before_after_kws` I found that it was added as to give a slightly less noisy output. 

The docs for AroundBlockScan#capture_neighbor_context only describe keywords as being a primary concern. I modified that code to only include lines that are keywords or ends. This reduces the output noise even more. 

This allows me to remove that `start_at_next_line` method.

One weird side effect of the prior logic is it would cause this code to produce this output:


```
        class OH
          def hello

          def hai
          end
        end
```

```
          1  class OH
        > 2    def hello
          4    def hai
          5    end
          6  end
```


But this code to produce this output:


```
        class OH
          def hello
          def hai
          end
        end
```

```
          1  class OH
        > 2    def hello
          4    end
          5  end
```
Note the missing `def hai`. The only difference between them is that space.

With this change, they're now both consistent.
@schneems schneems force-pushed the schneems/cleanup-output branch from 198073d to 4a54767 Compare April 14, 2023 22:36
@schneems schneems merged commit 68fdc9d into main Apr 14, 2023
@schneems schneems deleted the schneems/cleanup-output branch April 14, 2023 22:37
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.

2 participants