diff --git a/client/branded/src/components/panel/views/__snapshots__/HierarchicalLocationsView.test.tsx.snap b/client/branded/src/components/panel/views/__snapshots__/HierarchicalLocationsView.test.tsx.snap index 0f04e17e64de..d59caad45d36 100644 --- a/client/branded/src/components/panel/views/__snapshots__/HierarchicalLocationsView.test.tsx.snap +++ b/client/branded/src/components/panel/views/__snapshots__/HierarchicalLocationsView.test.tsx.snap @@ -99,7 +99,7 @@ exports[` displays a single location when complete - - - '], - [''], + [''], + [''], ] // Fake highlighting for line 46 in cmd/go-diff/go-diff.go export const highlightedLinesGoDiffGo = [ - [''], + [''], ] const MOCK_DEFINITIONS: LocationFields[] = [ diff --git a/client/web/src/codeintel/ReferencesPanel.tsx b/client/web/src/codeintel/ReferencesPanel.tsx index 69cb74e7cd4b..98c44fbd5c46 100644 --- a/client/web/src/codeintel/ReferencesPanel.tsx +++ b/client/web/src/codeintel/ReferencesPanel.tsx @@ -935,7 +935,7 @@ const CollapsibleLocationGroup: React.FunctionComponent< if (range !== undefined) { const lineNumber = range.start.line + 1 const lineContent = location.lines[range.start.line] - const tableLine = `` + const tableLine = `` return of([tableLine]) } return of([]) diff --git a/client/web/src/end-to-end/code-intel/repository-component.test.ts b/client/web/src/end-to-end/code-intel/repository-component.test.ts index 66fc1f0d54ce..ebfa12e9c26c 100644 --- a/client/web/src/end-to-end/code-intel/repository-component.test.ts +++ b/client/web/src/end-to-end/code-intel/repository-component.test.ts @@ -71,7 +71,7 @@ describe('Repository component', () => { } const hoverOver = async (lineBase1: number, characterBase1: number): Promise => { - const codeSelector = `td[data-line="${lineBase1}"] + .code` + const codeSelector = `th[data-line="${lineBase1}"] + .code` await driver.page.waitForSelector(codeSelector, { visible: true }) const findToken = (characterBase1Copy: number, codeSelectorCopy: string): string | undefined => { @@ -503,9 +503,9 @@ describe('Repository component', () => { ) await driver.page.waitForSelector(blobTableSelector) - await driver.page.waitForSelector('td[data-line="24"]', { visible: true }) + await driver.page.waitForSelector('th[data-line="24"]', { visible: true }) await driver.page.evaluate(() => { - document.querySelector('td[data-line="24"]')?.parentElement?.click() + document.querySelector('th[data-line="24"]')?.parentElement?.click() }) await driver.assertWindowLocation( diff --git a/client/web/src/integration/blob-viewer.test.ts b/client/web/src/integration/blob-viewer.test.ts index 2924033d97b1..a7eae77d5355 100644 --- a/client/web/src/integration/blob-viewer.test.ts +++ b/client/web/src/integration/blob-viewer.test.ts @@ -114,11 +114,11 @@ describe('Blob viewer', () => { aborted: false, html: // Note: whitespace in this string is significant. - '
@@ -110,7 +110,7 @@ exports[` displays a single location when complete
@@ -121,7 +121,7 @@ exports[` displays a single location when complete
@@ -326,7 +326,7 @@ exports[` displays multiple locations grouped by fi - - - - - ', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', ] const lineRanges = parameters.ranges.map(range => allLines.slice(range.startLine, range.endLine)) diff --git a/client/shared/src/testing/searchTestHelpers.ts b/client/shared/src/testing/searchTestHelpers.ts index 995968ccaf63..c582618d4ab7 100644 --- a/client/shared/src/testing/searchTestHelpers.ts +++ b/client/shared/src/testing/searchTestHelpers.ts @@ -546,63 +546,63 @@ export const COLLAPSABLE_SEARCH_RESULT: AggregateStreamingSearchResults = { export const HIGHLIGHTED_FILE_LINES = [ [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', ], ] export const HIGHLIGHTED_FILE_LINES_SIMPLE = [ [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', ], ] export const HIGHLIGHTED_FILE_LINES_LONG = [ [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', ], ] diff --git a/client/vscode/src/webview/theming/highlight.scss b/client/vscode/src/webview/theming/highlight.scss index fc5e578e67b5..88598e6145f3 100644 --- a/client/vscode/src/webview/theming/highlight.scss +++ b/client/vscode/src/webview/theming/highlight.scss @@ -8,8 +8,8 @@ // corresponding CSS variables for classes that the defaults do not. .sourcegraph-extension.theme-light, .sourcegraph-extension.theme-dark { - td.line, - td.line::before { + th.line, + th.line::before { color: var(--vscode-editorLineNumber-foreground); } diff --git a/client/web/src/codeintel/ReferencesPanel.mocks.ts b/client/web/src/codeintel/ReferencesPanel.mocks.ts index e6920fff6fa0..9b308bf64da0 100644 --- a/client/web/src/codeintel/ReferencesPanel.mocks.ts +++ b/client/web/src/codeintel/ReferencesPanel.mocks.ts @@ -29,30 +29,30 @@ const printFileContent = const highlightedDiffFileContent = [ '
@@ -337,7 +337,7 @@ exports[` displays multiple locations grouped by fi
@@ -348,7 +348,7 @@ exports[` displays multiple locations grouped by fi
@@ -359,7 +359,7 @@ exports[` displays multiple locations grouped by fi
@@ -370,7 +370,7 @@ exports[` displays multiple locations grouped by fi
@@ -497,7 +497,7 @@ exports[` displays partial locations before complet - - - - + ` ) diff --git a/client/codeintellify/src/testutils/sourcegraph/styles.css b/client/codeintellify/src/testutils/sourcegraph/styles.css index c1bc34d10d47..64ecd0506758 100644 --- a/client/codeintellify/src/testutils/sourcegraph/styles.css +++ b/client/codeintellify/src/testutils/sourcegraph/styles.css @@ -50,7 +50,7 @@ border-collapse: collapse; } -.sourcegraph-testcase code.code td.line { +.sourcegraph-testcase code.code th.line { text-align: right; padding-left: 0.5rem; min-width: 2rem; @@ -61,7 +61,7 @@ vertical-align: top; } -.sourcegraph-testcase td.line::before { +.sourcegraph-testcase th.line::before { content: attr(data-line); } diff --git a/client/search-ui/src/components/CodeExcerpt.module.scss b/client/search-ui/src/components/CodeExcerpt.module.scss index f65da8bc204f..cfd0f5f59aab 100644 --- a/client/search-ui/src/components/CodeExcerpt.module.scss +++ b/client/search-ui/src/components/CodeExcerpt.module.scss @@ -10,6 +10,7 @@ :global(.line) { min-width: 1.5rem; text-align: right; + font-weight: inherit; user-select: none; &::before { diff --git a/client/search-ui/src/components/CodeExcerpt.tsx b/client/search-ui/src/components/CodeExcerpt.tsx index 9c190b54a4e4..e987ae1f6c69 100644 --- a/client/search-ui/src/components/CodeExcerpt.tsx +++ b/client/search-ui/src/components/CodeExcerpt.tsx @@ -87,7 +87,7 @@ const domFunctions: DOMFunctions = { return row.cells[1] }, getCodeElementFromLineNumber: (codeView: HTMLElement, line: number): HTMLTableCellElement | null => { - const lineElement = codeView.querySelector(`td[data-line="${line}"]`) + const lineElement = codeView.querySelector(`th[data-line="${line}"]`) if (!lineElement) { return null } @@ -341,7 +341,7 @@ export const CodeExcerpt: React.FunctionComponent = ({ {range(startLine, endLine).map(index => ( - diff --git a/client/search-ui/src/components/CommitSearchResultMatch.module.scss b/client/search-ui/src/components/CommitSearchResultMatch.module.scss index 0c9e027623d8..718727d02180 100644 --- a/client/search-ui/src/components/CommitSearchResultMatch.module.scss +++ b/client/search-ui/src/components/CommitSearchResultMatch.module.scss @@ -32,7 +32,7 @@ table { margin-bottom: 0 !important; /* Override docsite Markdown table CSS. A currently open PR removes that CSS and lets us remove this override. */ } - td:global(.line) { + th:global(.line) { display: none; } td:global(.code) > span:first-child { diff --git a/client/search/src/integration/streaming-search-mocks.ts b/client/search/src/integration/streaming-search-mocks.ts index f153287f6d4a..f096a94a90dc 100644 --- a/client/search/src/integration/streaming-search-mocks.ts +++ b/client/search/src/integration/streaming-search-mocks.ts @@ -45,7 +45,7 @@ export const diffSearchStreamEvents: SearchEvent[] = [ export const diffHighlightResult: Partial = { highlightCode: () => ({ highlightCode: - '
@@ -508,7 +508,7 @@ exports[` displays partial locations before complet
@@ -519,7 +519,7 @@ exports[` displays partial locations before complet
diff --git a/client/codeintellify/src/testutils/sourcegraph/generate.ts b/client/codeintellify/src/testutils/sourcegraph/generate.ts index fe98e3665d4e..e3522f9cb5bd 100644 --- a/client/codeintellify/src/testutils/sourcegraph/generate.ts +++ b/client/codeintellify/src/testutils/sourcegraph/generate.ts @@ -5,7 +5,7 @@ export function generateSourcegraphCodeTable(lines: string[]): string { const code = lines .map( (line, index) => `
${line}
+ {/* create empty space to fill viewport (as if the blob content were already fetched, otherwise we'll overfetch) */}
mocha.opts mocha.opts\n
@@ -0,0 +3,2 @@\n
+--timeout 200\n
+src/**/*.test.ts\n
\\ No newline at end of file\n
package.json package.json\n
@@ -50,0 +54,3 @@\n
+ "exclude": [\n
+ "**/*.test.ts"\n
+ ],\n
@@ -54,1 +64,2 @@\n
- "serve": "parcel serve --no-hmr --out-file dist/extension.js src/extension.ts",\n
+ "test": "TS_NODE_COMPILER_OPTIONS='{\\"module\\":\\"commonjs\\"}' mocha --require ts-node/register --require source-map-support/register --opts mocha.opts",\n
+ "cover": "TS_NODE_COMPILER_OPTIONS='{\\"module\\":\\"commonjs\\"}' nyc --require ts-node/register --require source-map-support/register --all mocha --opts mocha.opts --timeout 10000",\n
@@ -57,2 +70,2 @@\n
- "sourcegraph:prepublish": "parcel build src/extension.ts"\n
+ "sourcegraph:prepublish": "yarn typecheck && yarn test && yarn build"\n
},\n
yarn.lock yarn.lock\n
@@ -3736,0 +4204,3 @@ number-is-nan@^1.0.0:\n
+ spawn-wrap "^1.4.2"\n
+ test-exclude "^5.1.0"\n
+ uuid "^3.3.2"\n
@@ -5550,1 +6166,5 @@ terser@^3.7.3, terser@^3.8.1:\n
\n
+test-exclude@^5.1.0:\n
+ version "5.1.0"\n
+ resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.1.0.tgz#6ba6b25179d2d38724824661323b73e03c0c1de1"\n
+ integrity sha512-gwf0S2fFsANC55fSeSqpb8BYk6w3FDvwZxfNjeF6FRgvFa43r+7wRiA/Q0IxoRU37wB/LE8IQ4221BsNucTaCA==
', + '
mocha.opts mocha.opts\n
@@ -0,0 +3,2 @@\n
+--timeout 200\n
+src/**/*.test.ts\n
\\ No newline at end of file\n
package.json package.json\n
@@ -50,0 +54,3 @@\n
+ "exclude": [\n
+ "**/*.test.ts"\n
+ ],\n
@@ -54,1 +64,2 @@\n
- "serve": "parcel serve --no-hmr --out-file dist/extension.js src/extension.ts",\n
+ "test": "TS_NODE_COMPILER_OPTIONS='{\\"module\\":\\"commonjs\\"}' mocha --require ts-node/register --require source-map-support/register --opts mocha.opts",\n
+ "cover": "TS_NODE_COMPILER_OPTIONS='{\\"module\\":\\"commonjs\\"}' nyc --require ts-node/register --require source-map-support/register --all mocha --opts mocha.opts --timeout 10000",\n
@@ -57,2 +70,2 @@\n
- "sourcegraph:prepublish": "parcel build src/extension.ts"\n
+ "sourcegraph:prepublish": "yarn typecheck && yarn test && yarn build"\n
},\n
yarn.lock yarn.lock\n
@@ -3736,0 +4204,3 @@ number-is-nan@^1.0.0:\n
+ spawn-wrap "^1.4.2"\n
+ test-exclude "^5.1.0"\n
+ uuid "^3.3.2"\n
@@ -5550,1 +6166,5 @@ terser@^3.7.3, terser@^3.8.1:\n
\n
+test-exclude@^5.1.0:\n
+ version "5.1.0"\n
+ resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.1.0.tgz#6ba6b25179d2d38724824661323b73e03c0c1de1"\n
+ integrity sha512-gwf0S2fFsANC55fSeSqpb8BYk6w3FDvwZxfNjeF6FRgvFa43r+7wRiA/Q0IxoRU37wB/LE8IQ4221BsNucTaCA==
', }), } @@ -77,7 +77,7 @@ export const commitSearchStreamEvents: SearchEvent[] = [ export const commitHighlightResult: Partial = { highlightCode: () => ({ highlightCode: - '
add more tests, use the Sourcegraph stubs api and improve repo matching. (#13)\n
\n
* add more tests, refactor to use extension api stubs\n
* improve repo matching\n
Co-Authored-By: Felix Becker
', + '
add more tests, use the Sourcegraph stubs api and improve repo matching. (#13)\n
\n
* add more tests, refactor to use extension api stubs\n
* improve repo matching\n
Co-Authored-By: Felix Becker
', }), } @@ -266,84 +266,84 @@ export const mixedSearchStreamEvents: SearchEvent[] = [ export const highlightFileResult: Partial = { HighlightedFile: (parameters: FetchFileParameters) => { const allLines = [ - '
import { index } from './index'\n
import { Edge, Vertex } from 'lsif-protocol'\n
import _ from 'lodash'\n
import * as path from 'path'\n
import * as cp from 'child_process'\n
\n
const GENERATE = false\n
\n
function generate(example: string): void {\n
cp.execFileSync('./generate-csv', ['$CXX -c *.cpp'], {\n
env: {\n
ABSROOTDIR: path.resolve(`examples/${example}/root`),\n
ABSOUTDIR: path.resolve(`examples/${example}/output`),\n
CLEAN: 'true',\n
},\n
})\n
}\n
\n
async function indexExample(example: string): Promise<(Edge | Vertex)[]> {\n
if (GENERATE) {\n
generate(example)\n
}\n
\n
const output: (Edge | Vertex)[] = []\n
\n
await index({\n
csvFileGlob: `examples/${example}/output/*.csv`,\n
root: `examples/${example}/root`,\n
emit: item =>\n
new Promise(resolve => {\n
output.push(item)\n
resolve()\n
}),\n
})\n
\n
return output\n
}\n
\n
test('does not emit items with duplicate IDs', async () => {\n
const output = await indexExample('five')\n
\n
const setsOfDupes = _(output)\n
.groupBy(item => item.id)\n
.values()\n
.map(group => ({ group, count: group.length }))\n
.value()\n
.filter(({ count }) => count > 1)\n
.map(({ group }) => group)\n
\n
if (setsOfDupes.length > 0) {\n
fail(\n
new Error(\n
`Sets of lines with duplicate IDs:\\n` +\n
setsOfDupes\n
.map(dupes =>\n
dupes.map(item => JSON.stringify(item)).join('\\n')\n
)\n
.join('\\n\\n')\n
)\n
)\n
}\n
})\n
\n
test('five', async () => {\n
const output = (await indexExample('five')).map(v => JSON.stringify(v))\n
\n
expect(output.join('\\n')).toMatchSnapshot()\n
})\n
\n
test('cross-app', async () => {\n
const app = (await indexExample('cross-app')).map(v => JSON.stringify(v))\n
expect(app.join('\\n')).toMatchSnapshot()\n
})\n
\n
test('cross-lib', async () => {\n
const lib = (await indexExample('cross-lib')).map(v => JSON.stringify(v))\n
expect(lib.join('\\n')).toMatchSnapshot()\n
})
import { index } from './index'\n
import { Edge, Vertex } from 'lsif-protocol'\n
import _ from 'lodash'\n
import * as path from 'path'\n
import * as cp from 'child_process'\n
\n
const GENERATE = false\n
\n
function generate(example: string): void {\n
cp.execFileSync('./generate-csv', ['$CXX -c *.cpp'], {\n
env: {\n
ABSROOTDIR: path.resolve(`examples/${example}/root`),\n
ABSOUTDIR: path.resolve(`examples/${example}/output`),\n
CLEAN: 'true',\n
},\n
})\n
}\n
\n
async function indexExample(example: string): Promise<(Edge | Vertex)[]> {\n
if (GENERATE) {\n
generate(example)\n
}\n
\n
const output: (Edge | Vertex)[] = []\n
\n
await index({\n
csvFileGlob: `examples/${example}/output/*.csv`,\n
root: `examples/${example}/root`,\n
emit: item =>\n
new Promise(resolve => {\n
output.push(item)\n
resolve()\n
}),\n
})\n
\n
return output\n
}\n
\n
test('does not emit items with duplicate IDs', async () => {\n
const output = await indexExample('five')\n
\n
const setsOfDupes = _(output)\n
.groupBy(item => item.id)\n
.values()\n
.map(group => ({ group, count: group.length }))\n
.value()\n
.filter(({ count }) => count > 1)\n
.map(({ group }) => group)\n
\n
if (setsOfDupes.length > 0) {\n
fail(\n
new Error(\n
`Sets of lines with duplicate IDs:\\n` +\n
setsOfDupes\n
.map(dupes =>\n
dupes.map(item => JSON.stringify(item)).join('\\n')\n
)\n
.join('\\n\\n')\n
)\n
)\n
}\n
})\n
\n
test('five', async () => {\n
const output = (await indexExample('five')).map(v => JSON.stringify(v))\n
\n
expect(output.join('\\n')).toMatchSnapshot()\n
})\n
\n
test('cross-app', async () => {\n
const app = (await indexExample('cross-app')).map(v => JSON.stringify(v))\n
expect(app.join('\\n')).toMatchSnapshot()\n
})\n
\n
test('cross-lib', async () => {\n
const lib = (await indexExample('cross-lib')).map(v => JSON.stringify(v))\n
expect(lib.join('\\n')).toMatchSnapshot()\n
})
language: go↵
go:↵
- tip↵
install:↵
- export GOPATH="$HOME/gopath"↵
- mkdir -p "$GOPATH/src/golang.org/x"↵
- mv "$TRAVIS_BUILD_DIR" "$GOPATH/src/golang.org/x/oauth2"↵
- go get -v -t -d golang.org/x/oauth2/...↵
script:↵
- go test -v golang.org/x/oauth2/...
language: go↵
go:↵
- tip↵
install:↵
- export GOPATH="$HOME/gopath"↵
- mkdir -p "$GOPATH/src/golang.org/x"↵
- mv "$TRAVIS_BUILD_DIR" "$GOPATH/src/golang.org/x/oauth2"↵
- go get -v -t -d golang.org/x/oauth2/...↵
script:↵
- go test -v golang.org/x/oauth2/...
first line of code
second line of code
third line of code
fourth
fifth
sixth
seventh
eighth
ninth
tenth
first line of code
second line of code
third line of code
fourth
fifth
sixth
seventh
eighth
ninth
tenth
// Copyright 2014 The Go Authors. All rights reserved.↵
// Use of this source code is governed by a BSD-style↵
// license that can be found in the LICENSE file.↵
package oauth2_test↵
import (↵
"context"↵
"fmt"↵
"log"↵
"net/http"↵
"time"↵
"golang.org/x/oauth2"↵
)↵
func ExampleConfig() {↵
ctx := context.Background()↵
conf := &oauth2.Config{↵
ClientID: "YOUR_CLIENT_ID",↵
ClientSecret: "YOUR_CLIENT_SECRET",↵
Scopes: []string{"SCOPE1", "SCOPE2"},↵
Endpoint: oauth2.Endpoint{↵
AuthURL: "https://provider.com/o/oauth2/auth",↵
// Copyright 2014 The Go Authors. All rights reserved.↵
// Use of this source code is governed by a BSD-style↵
// license that can be found in the LICENSE file.↵
package oauth2_test↵
import (↵
"context"↵
"fmt"↵
"log"↵
"net/http"↵
"time"↵
"golang.org/x/oauth2"↵
)↵
func ExampleConfig() {↵
ctx := context.Background()↵
conf := &oauth2.Config{↵
ClientID: "YOUR_CLIENT_ID",↵
ClientSecret: "YOUR_CLIENT_SECRET",↵
Scopes: []string{"SCOPE1", "SCOPE2"},↵
Endpoint: oauth2.Endpoint{↵
AuthURL: "https://provider.com/o/oauth2/auth",↵
', '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', '
package diff\n
\n
import (\n
\t\u0026quot;bytes\u0026quot;\n
\t\u0026quot;time\u0026quot;\n
)\n
\n
// A FileDiff represents a unified diff for a single file.\n
//\n
// A file unified diff has a header that resembles the following:\n
//\n
// --- oldname\t2009-10-11 15:12:20.000000000 -0700\n
// +++ newname\t2009-10-11 15:12:30.000000000 -0700\n
type FileDiff struct {\n
\t// the original name of the file\n
\tOrigName string\n
\t// the original timestamp (nil if not present)\n
\tOrigTime *time.Time\n
\t// the new name of the file (often same as OrigName)\n
\tNewName string\n
\t// the new timestamp (nil if not present)\n
\tNewTime *time.Time\n
\t// extended header lines (e.g., git\u0026#39;s \u0026quot;new mode \u0026lt;mode\u0026gt;\u0026quot;, \u0026quot;rename from \u0026lt;path\u0026gt;\u0026quot;, etc.)\n
\tExtended []string\n
\t// hunks that were changed from orig to new\n
package diff\n
\n
import (\n
\t\u0026quot;bytes\u0026quot;\n
\t\u0026quot;time\u0026quot;\n
)\n
\n
// A FileDiff represents a unified diff for a single file.\n
//\n
// A file unified diff has a header that resembles the following:\n
//\n
// --- oldname\t2009-10-11 15:12:20.000000000 -0700\n
// +++ newname\t2009-10-11 15:12:30.000000000 -0700\n
type FileDiff struct {\n
\t// the original name of the file\n
\tOrigName string\n
\t// the original timestamp (nil if not present)\n
\tOrigTime *time.Time\n
\t// the new name of the file (often same as OrigName)\n
\tNewName string\n
\t// the new timestamp (nil if not present)\n
\tNewTime *time.Time\n
\t// extended header lines (e.g., git\u0026#39;s \u0026quot;new mode \u0026lt;mode\u0026gt;\u0026quot;, \u0026quot;rename from \u0026lt;path\u0026gt;\u0026quot;, etc.)\n
\tExtended []string\n
\t// hunks that were changed from orig to new\n
', ].join('') @@ -172,13 +172,13 @@ function buildMockLocation({ // Fake highlighting for lines 16 and 52 in diff/diff.go export const highlightedLinesDiffGo = [ - ['
line 16
line 52
line 16
line 52
line 46
line 46
${lineContent}
${lineContent}
' + + '' + - '' + - '
' + '' + '// ' + 'Log to console\n
' + + '
' + '' + 'console' + '.' + @@ -128,7 +128,7 @@ describe('Blob viewer', () => { '"Hello world' + '"' + ')\n
' + + '
' + '' + '// ' + 'Third line\n
', @@ -200,11 +200,11 @@ describe('Blob viewer', () => { html: // Note: whitespace in this string is significant. '' + - '' + - '
' + + '' + '' + '// ' + 'Log to console\n
' + + '
' + '' + 'console' + '.' + @@ -471,11 +471,11 @@ describe('Blob viewer', () => { aborted: false, html: // Note: whitespace in this string is significant. - '
' + + '' + - '' + - '
' + '' + '// ' + 'Log to console\n
' + + '
' + '' + 'console' + '.' + @@ -485,7 +485,7 @@ describe('Blob viewer', () => { '"Hello world' + '"' + ')\n
' + + '
' + '' + '// ' + 'Third line\n
', @@ -735,9 +735,9 @@ describe('Blob viewer', () => { aborted: false, html: // Note: whitespace in this string is significant. - '\n' + - '
// First word line\n' + - '
// Second line
// Third word line
', + '\n' + + '
// First word line\n' + + '
// Second line
// Third word line
', lsif: '', }, } @@ -748,9 +748,9 @@ describe('Blob viewer', () => { aborted: false, html: // Note: whitespace in this string is significant. - '\n' + - '
// First line\n' + - '
// Second word line
// Third line
', + '\n' + + '
// First line\n' + + '
// Second word line
// Third line
', lsif: '', }, } @@ -932,12 +932,12 @@ describe('Blob viewer', () => { highlight: { aborted: false, html: - '
' + + '' + - '
' + '' + '//' + ` file path: ${filePath}\n` + '
' + + '
' + '' + '' + 'console' + @@ -968,12 +968,12 @@ describe('Blob viewer', () => { highlight: { aborted: false, html: - '
' + + '' + - '
' + '' + '//' + ` file path: ${filePath}\n` + '
' + + '
' + '' + '' + 'console' + diff --git a/client/web/src/integration/notebook.test.ts b/client/web/src/integration/notebook.test.ts index 8d48bb190b09..6e717d17fcec 100644 --- a/client/web/src/integration/notebook.test.ts +++ b/client/web/src/integration/notebook.test.ts @@ -422,7 +422,7 @@ describe('Search Notebook', () => { ) // Wait for highlighted code to load - await driver.page.waitForSelector(`${fileBlockSelector} td.line`, { visible: true }) + await driver.page.waitForSelector(`${fileBlockSelector} th.line`, { visible: true }) // Refocus the entire block (prevents jumping content for below actions) await driver.page.click(fileBlockSelector) @@ -617,7 +617,7 @@ https://sourcegraph.test:3443/github.com/sourcegraph/sourcegraph@branch/-/blob/c await driver.page.click(`${symbolBlockSelector} [data-testid="symbol-suggestion-button"]`) // Wait for highlighted code to load - await driver.page.waitForSelector(`${symbolBlockSelector} td.line`, { visible: true }) + await driver.page.waitForSelector(`${symbolBlockSelector} th.line`, { visible: true }) // Refocus the entire block (prevents jumping content for below actions) await driver.page.click(symbolBlockSelector) @@ -708,7 +708,7 @@ https://sourcegraph.test:3443/github.com/sourcegraph/sourcegraph@branch/-/blob/c const fileBlockSelector = blockSelector(blockIds[2]) // Wait for highlighted code to load - await driver.page.waitForSelector(`${fileBlockSelector} td.line`, { visible: true }) + await driver.page.waitForSelector(`${fileBlockSelector} th.line`, { visible: true }) const fileBlockHeaderText = await getFileBlockHeaderText(fileBlockSelector) expect(fileBlockHeaderText).toEqual('sourcegraph/sourcegraph›client/search/src/index.ts') diff --git a/client/web/src/repo/blob/BlameColumn.tsx b/client/web/src/repo/blob/BlameColumn.tsx index 980b5026702d..227db06b8c09 100644 --- a/client/web/src/repo/blob/BlameColumn.tsx +++ b/client/web/src/repo/blob/BlameColumn.tsx @@ -51,7 +51,7 @@ export const BlameColumn = React.memo(({ isBlameVisible, codeV // if no other columns with decorations if (!row?.querySelector(`.${styles.decoration}`)) { // remove line number cell extra horizontal padding - row?.querySelector('td.line')?.classList.remove('px-2') + row?.querySelector('th.line')?.classList.remove('px-2') } } @@ -71,7 +71,7 @@ export const BlameColumn = React.memo(({ isBlameVisible, codeV cell.classList.add(styles.decoration) // add line number cell extra horizontal padding - row.querySelector('td.line')?.classList.add('px-2') + row.querySelector('th.line')?.classList.add('px-2') // add decorations wrapper const wrapper = document.createElement('div') diff --git a/client/web/src/repo/blob/Blob.module.scss b/client/web/src/repo/blob/Blob.module.scss index 1d07384aef48..d32704106be4 100644 --- a/client/web/src/repo/blob/Blob.module.scss +++ b/client/web/src/repo/blob/Blob.module.scss @@ -13,7 +13,7 @@ border-collapse: collapse; } - td:global(.line) { + th:global(.line) { &::before { // draw line number with css so it cannot be copied to clipboard content: attr(data-line); @@ -43,13 +43,13 @@ } } - &:first-child td:global(.line) { + &:first-child th:global(.line) { // place bottom spacer below the line number set with ::before pseudo-element display: flex; flex-direction: column-reverse; } - &:first-child:last-child td:global(.line) { + &:first-child:last-child th:global(.line) { // place the line number set with ::before pseudo-element between top and bottom spacers &::before { order: 1; @@ -61,7 +61,7 @@ } } - td:global(.line), + th:global(.line), td:global(.code) { padding: 0; } diff --git a/client/web/src/repo/blob/Blob.tsx b/client/web/src/repo/blob/Blob.tsx index 67acf58c3ebf..b28113e245a8 100644 --- a/client/web/src/repo/blob/Blob.tsx +++ b/client/web/src/repo/blob/Blob.tsx @@ -185,7 +185,7 @@ const domFunctions = { if (!row) { throw new Error('Could not find closest row for codeCell') } - const numberCell = row.querySelector('td.line') + const numberCell = row.querySelector('th.line') if (!numberCell || !numberCell.dataset.line) { throw new Error('Could not find line number') } diff --git a/client/web/src/repo/compare/dom-functions.ts b/client/web/src/repo/compare/dom-functions.ts index f929c97b4d35..69249bd0eb90 100644 --- a/client/web/src/repo/compare/dom-functions.ts +++ b/client/web/src/repo/compare/dom-functions.ts @@ -22,7 +22,7 @@ export const diffDomFunctions: DOMFunctions = { // Find all line number cells in this row const lineNumberCells = codeCell .closest('tr') - ?.querySelectorAll('td[data-line]') as NodeListOf + ?.querySelectorAll('[data-line]') as NodeListOf // If there are line numbers... if (lineNumberCells?.length) { // Pick the second (last, using `pop`) line number cell, since code-intel will diff --git a/cmd/frontend/internal/highlight/highlight.go b/cmd/frontend/internal/highlight/highlight.go index bfa49a07cb1c..471cae68cb25 100644 --- a/cmd/frontend/internal/highlight/highlight.go +++ b/cmd/frontend/internal/highlight/highlight.go @@ -562,10 +562,10 @@ func generatePlainTable(code string) (*HighlightedCode, error) { tr := &html.Node{Type: html.ElementNode, DataAtom: atom.Tr, Data: atom.Tr.String()} table.AppendChild(tr) - tdLineNumber := &html.Node{Type: html.ElementNode, DataAtom: atom.Td, Data: atom.Td.String()} - tdLineNumber.Attr = append(tdLineNumber.Attr, html.Attribute{Key: "class", Val: "line"}) - tdLineNumber.Attr = append(tdLineNumber.Attr, html.Attribute{Key: "data-line", Val: fmt.Sprint(row + 1)}) - tr.AppendChild(tdLineNumber) + thLineNumber := &html.Node{Type: html.ElementNode, DataAtom: atom.Th, Data: atom.Th.String()} + thLineNumber.Attr = append(thLineNumber.Attr, html.Attribute{Key: "class", Val: "line"}) + thLineNumber.Attr = append(thLineNumber.Attr, html.Attribute{Key: "data-line", Val: fmt.Sprint(row + 1)}) + tr.AppendChild(thLineNumber) codeCell := &html.Node{Type: html.ElementNode, DataAtom: atom.Td, Data: atom.Td.String()} codeCell.Attr = append(codeCell.Attr, html.Attribute{Key: "class", Val: "code"}) diff --git a/cmd/frontend/internal/highlight/highlight_test.go b/cmd/frontend/internal/highlight/highlight_test.go index 2aea0e3ee5d2..8bc10bf6e74c 100644 --- a/cmd/frontend/internal/highlight/highlight_test.go +++ b/cmd/frontend/internal/highlight/highlight_test.go @@ -52,8 +52,8 @@ func TestGeneratePlainTable(t *testing.T) { line 2 ` - want := template.HTML(`
line 1
line 2
-
+ want := template.HTML(`
line 1
line 2
+
`) response, err := generatePlainTable(input) if err != nil { @@ -71,8 +71,8 @@ func TestGeneratePlainTableSecurity(t *testing.T) { ` - want := template.HTML(`
<strong>line 1</strong>
<script>alert("line 2")</script>
-
+ want := template.HTML(`
<strong>line 1</strong>
<script>alert("line 2")</script>
+
`) response, err := generatePlainTable(input) if err != nil { diff --git a/cmd/frontend/internal/highlight/html.go b/cmd/frontend/internal/highlight/html.go index 5136c7280164..c326f17f472a 100644 --- a/cmd/frontend/internal/highlight/html.go +++ b/cmd/frontend/internal/highlight/html.go @@ -228,10 +228,10 @@ func newHtmlRow(row int32, includeLineNumbers bool) (htmlRow, htmlCode *html.Nod tr := &html.Node{Type: html.ElementNode, DataAtom: atom.Tr, Data: atom.Tr.String()} if includeLineNumbers { - tdLineNumber := &html.Node{Type: html.ElementNode, DataAtom: atom.Td, Data: atom.Td.String()} - tdLineNumber.Attr = append(tdLineNumber.Attr, html.Attribute{Key: "class", Val: "line"}) - tdLineNumber.Attr = append(tdLineNumber.Attr, html.Attribute{Key: "data-line", Val: fmt.Sprint(row + 1)}) - tr.AppendChild(tdLineNumber) + thLineNumber := &html.Node{Type: html.ElementNode, DataAtom: atom.Thead, Data: atom.Thead.String()} + thLineNumber.Attr = append(thLineNumber.Attr, html.Attribute{Key: "class", Val: "line"}) + thLineNumber.Attr = append(thLineNumber.Attr, html.Attribute{Key: "data-line", Val: fmt.Sprint(row + 1)}) + tr.AppendChild(thLineNumber) } codeCell := &html.Node{Type: html.ElementNode, DataAtom: atom.Td, Data: atom.Td.String()} diff --git a/docker-images/syntax-highlighter/crates/sg-syntax/src/sg_syntect.rs b/docker-images/syntax-highlighter/crates/sg-syntax/src/sg_syntect.rs index bc8f2ff5b103..ea8f546334d6 100644 --- a/docker-images/syntax-highlighter/crates/sg-syntax/src/sg_syntect.rs +++ b/docker-images/syntax-highlighter/crates/sg-syntax/src/sg_syntect.rs @@ -12,7 +12,7 @@ use syntect::{ /// /// /// -///
+/// /// /// /// package @@ -181,7 +181,7 @@ fn close_table(s: &mut String) { fn open_row(s: &mut String, i: usize) { write!( s, - "
", + "
", i + 1 ) .unwrap(); @@ -256,7 +256,7 @@ mod tests { let expected = "\ \ \ -
\ + \ \
\ \ @@ -286,7 +286,7 @@ mod tests { let expected = "\ \ \ - \ @@ -310,7 +310,7 @@ mod tests { let expected = "
\ + \ \
<div>test</div>
\
\ \ \ - \ @@ -335,7 +335,7 @@ mod tests { let expected = "
\ + \ \
package main\n
\
\ \ \ - \ \ \ - \ \ \ -
\ + \ \
\ \ @@ -359,7 +359,7 @@ mod tests {
\ + \ \
\ \n\ @@ -367,7 +367,7 @@ mod tests {
\ + \ \
\ \