@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make very minor generality improvements to the scope selector

Summary:
See PHI985. I think we pretty much need to start applying language-specific rules, but we can apply at least one more relatively language-agnostic rule: don't match lines which are indented 3+ levels.

In C++, we may have symbols like this:

```
class X {
public:
int m() { ... }
}
```

..but I believe no mainstream language puts symbol definitions 3+ levels deep.

Also clean up some of the tab handling very slightly.

Test Plan: Tests pass, looked at some C++ code and got slightly better (but still not great) matches.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20479

+14 -6
+14 -6
src/infrastructure/diff/PhabricatorDiffScopeEngine.php
··· 83 83 continue; 84 84 } 85 85 86 + // Don't match context lines which are too deeply indented, since they 87 + // are very unlikely to be symbol definitions. 88 + if ($depth > 2) { 89 + continue; 90 + } 91 + 86 92 // The depth is the same as (or greater than) the depth we started with, 87 93 // so this isn't a possible match. 88 94 if ($depth >= $line_depth) { ··· 109 115 return $this->lineDepthMap; 110 116 } 111 117 118 + private function getTabWidth() { 119 + // TODO: This should be configurable once we handle tab widths better. 120 + return 2; 121 + } 122 + 112 123 private function newLineDepthMap() { 113 124 $text_map = $this->getLineTextMap(); 114 - 115 - // TODO: This should be configurable once we handle tab widths better. 116 - $tab_width = 2; 125 + $tab_width = $this->getTabWidth(); 117 126 118 127 $depth_map = array(); 119 128 foreach ($text_map as $line_number => $line_text) { ··· 143 152 } 144 153 145 154 // Round down to cheat our way through the " *" parts of docblock 146 - // comments. This is generally a reasonble heuristic because odd tab 147 - // widths are exceptionally rare. 148 - $depth = ($count >> 1); 155 + // comments. 156 + $depth = (int)floor($count / $tab_width); 149 157 150 158 $depth_map[$line_number] = $depth; 151 159 }