fix exponential recursion in detail screen config

by memoizing lcsMerge. Also:

- simplify it to return the merged result rather than an internal data
  structure
- do not keep track of the whole longest submatch, just its length, for
  simplicity