check context lines in results model
MODIFY
spec/results-model-spec.js
spec/results-model-spec.js
@@ -10,6 +10,8 @@ describe("ResultsModel", () => {
beforeEach(async () => {
atom.config.set("core.excludeVcsIgnoredPaths", false);
+ atom.config.set("find-and-replace.searchContextLineCountBefore", 2);
+ atom.config.set("find-and-replace.searchContextLineCountAfter", 3);
atom.project.setPaths([path.join(__dirname, "fixtures")]);
editor = await atom.workspace.open("sample.js");
@@ -33,6 +35,16 @@ describe("ResultsModel", () => {
expect(resultsModel.getPathCount()).toBe(1);
expect(resultsModel.getMatchCount()).toBe(6);
expect(resultsModel.getPaths()).toEqual([editor.getPath()]);
+ if (parseFloat(atom.getVersion()) >= 1.17) {
+ expect(result.matches[0].leadingContextLines.length).toBe(1);
+ expect(result.matches[0].leadingContextLines[0]).toBe("var quicksort = function () {");
+ expect(result.matches[0].trailingContextLines.length).toBe(3);
+ expect(result.matches[0].trailingContextLines[0]).toBe(" if (items.length <= 1) return items;");
+ expect(result.matches[0].trailingContextLines[1]).toBe(" var pivot = items.shift(), current, left = [], right = [];");
+ expect(result.matches[0].trailingContextLines[2]).toBe(" while(items.length > 0) {");
+ expect(result.matches[5].leadingContextLines.length).toBe(2);
+ expect(result.matches[5].trailingContextLines.length).toBe(3);
+ }
editor.setText("there are some items in here");
advanceClock(editor.buffer.stoppedChangingDelay);
@@ -44,6 +56,10 @@ describe("ResultsModel", () => {
expect(resultsModel.getMatchCount()).toBe(1);
expect(resultsModel.getPaths()).toEqual([editor.getPath()]);
expect(result.matches[0].lineText).toBe("there are some items in here");
+ if (parseFloat(atom.getVersion()) >= 1.17) {
+ expect(result.matches[0].leadingContextLines.length).toBe(0);
+ expect(result.matches[0].trailingContextLines.length).toBe(0);
+ }
editor.setText("no matches in here");
advanceClock(editor.buffer.stoppedChangingDelay);

check context lines in results model