提交 186f21da 编写于 作者: R Rob Lourens

Fix #67113 - missing context in search copy results

上级 9301aefe
......@@ -653,7 +653,7 @@ function matchToString(match: Match, indent = 0): string {
const getFirstLinePrefix = () => `${match.range().startLineNumber},${match.range().startColumn}`;
const getOtherLinePrefix = (i: number) => match.range().startLineNumber + i + '';
const fullMatchLines = match.fullMatchText().split(/\r?\n/g);
const fullMatchLines = match.fullPreviewLines();
const largestPrefixSize = fullMatchLines.reduce((largest, _, i) => {
const thisSize = i === 0 ?
getFirstLinePrefix().length :
......
......@@ -135,6 +135,10 @@ export class Match {
return thisMatchPreviewLines.join('\n');
}
fullPreviewLines(): string[] {
return this._fullPreviewLines.slice(this._fullPreviewRange.startLineNumber, this._fullPreviewRange.endLineNumber + 1);
}
getMatchString(): string {
return this._oneLinePreviewText.substring(this._rangeInPreviewText.startColumn - 1, this._rangeInPreviewText.endColumn - 1);
}
......
......@@ -40,6 +40,9 @@ suite('SearchResult', () => {
assert.equal(lineMatch.range().startColumn, 1);
assert.equal(lineMatch.range().endColumn, 4);
assert.equal('file:///folder/file.txt>[2,1 -> 2,4]foo', lineMatch.id());
assert.equal(lineMatch.fullMatchText(), 'foo');
assert.equal(lineMatch.fullMatchText(true), 'foo bar');
});
test('Line Match - Remove', function () {
......@@ -312,50 +315,6 @@ suite('SearchResult', () => {
return voidPromise.then(() => assert.ok(testObject.isEmpty()));
});
//// ----- utils
//function lineHasDecorations(model: editor.IModel, lineNumber: number, decorations: { start: number; end: number; }[]): void {
// let lineDecorations:typeof decorations = [];
// let decs = model.getLineDecorations(lineNumber);
// for (let i = 0, len = decs.length; i < len; i++) {
// lineDecorations.push({
// start: decs[i].range.startColumn,
// end: decs[i].range.endColumn
// });
// }
// assert.deepEqual(lineDecorations, decorations);
//}
//
//function lineHasNoDecoration(model: editor.IModel, lineNumber: number): void {
// lineHasDecorations(model, lineNumber, []);
//}
//
//function lineHasDecoration(model: editor.IModel, lineNumber: number, start: number, end: number): void {
// lineHasDecorations(model, lineNumber, [{
// start: start,
// end: end
// }]);
//}
//// ----- end utils
//
//test('Model Highlights', function () {
//
// let fileMatch = instantiation.createInstance(FileMatch, null, toUri('folder\\file.txt'));
// fileMatch.add(new Match(fileMatch, 'line2', 1, 0, 2));
// fileMatch.connect();
// lineHasDecoration(oneModel, 2, 1, 3);
//});
//
//test('Dispose', () => {
//
// let fileMatch = instantiation.createInstance(FileMatch, null, toUri('folder\\file.txt'));
// fileMatch.add(new Match(fileMatch, 'line2', 1, 0, 2));
// fileMatch.connect();
// lineHasDecoration(oneModel, 2, 1, 3);
//
// fileMatch.dispose();
// lineHasNoDecoration(oneModel, 2);
//});
function aFileMatch(path: string, searchResult?: SearchResult, ...lineMatches: ITextSearchMatch[]): FileMatch {
const rawMatch: IFileMatch = {
resource: URI.file('/' + path),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册