Skip to content

Commit 9aed4fe

Browse files
authored
fix: Fix issue with .gitignore files (#4254)
1 parent 95978d2 commit 9aed4fe

File tree

13 files changed

+190
-170
lines changed

13 files changed

+190
-170
lines changed

package-lock.json

Lines changed: 132 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,15 @@
266266
"type": "webview",
267267
"id": "cSpellInfoView",
268268
"when": "cSpell.context.displayCSpellInfo",
269+
"icon": "$(lightbulb)",
269270
"name": "Spell Checker"
270271
}
271272
],
272273
"cspell-regexp-explorer": [
273274
{
274275
"id": "cSpellRegExpView",
275276
"name": "Regular Expressions",
277+
"icon": "$(code)",
276278
"when": "config.cSpell.experimental.enableRegexpView"
277279
}
278280
],
@@ -4089,10 +4091,10 @@
40894091
"vitest": "^3.0.9"
40904092
},
40914093
"dependencies": {
4092-
"@cspell/cspell-bundled-dicts": "^8.17.5",
4093-
"@cspell/cspell-types": "^8.17.5",
4094+
"@cspell/cspell-bundled-dicts": "^8.18.0",
4095+
"@cspell/cspell-types": "^8.18.0",
40944096
"@cspell/dict-cspell-bundle": "^1.0.39",
4095-
"cspell": "^8.17.5",
4097+
"cspell": "^8.18.0",
40964098
"regexp-worker": "^3.0.0"
40974099
},
40984100
"vsce": {

packages/__utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"watch": "tsc -p . --watch"
4747
},
4848
"dependencies": {
49-
"@cspell/url": "^8.17.5",
49+
"@cspell/url": "^8.18.0",
5050
"vscode-uri": "^3.1.0"
5151
},
5252
"engines": {

packages/_integrationTests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"author": "",
2525
"license": "MIT",
2626
"devDependencies": {
27-
"@cspell/cspell-types": "^8.17.5",
27+
"@cspell/cspell-types": "^8.18.0",
2828
"@cspell/dict-de-de": "^4.0.3",
2929
"@types/chai": "^5.2.1",
3030
"@types/decompress": "^4.2.7",

packages/_server/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
"yargs": "^17.7.2"
4141
},
4242
"dependencies": {
43-
"@cspell/cspell-bundled-dicts": "^8.17.5",
44-
"@cspell/cspell-pipe": "^8.17.5",
45-
"@cspell/cspell-types": "^8.17.5",
46-
"@cspell/url": "^8.17.5",
43+
"@cspell/cspell-bundled-dicts": "^8.18.0",
44+
"@cspell/cspell-pipe": "^8.18.0",
45+
"@cspell/cspell-types": "^8.18.0",
46+
"@cspell/url": "^8.18.0",
4747
"@internal/common-utils": "file:../__utils",
48-
"cspell-config-lib": "^8.17.5",
49-
"cspell-gitignore": "^8.17.5",
50-
"cspell-glob": "^8.17.5",
51-
"cspell-io": "^8.17.5",
52-
"cspell-lib": "^8.17.5",
48+
"cspell-config-lib": "^8.18.0",
49+
"cspell-gitignore": "^8.18.0",
50+
"cspell-glob": "^8.18.0",
51+
"cspell-io": "^8.18.0",
52+
"cspell-lib": "^8.18.0",
5353
"gensequence": "^7.0.0",
5454
"json-rpc-api": "file:../json-rpc-api",
5555
"rxjs": "^7.8.2",

packages/_server/src/config/documentSettings.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ export class DocumentSettings {
238238
if (root) {
239239
this.gitIgnore.addRoots([uriToGlobPath(root)]);
240240
}
241-
return await this.gitIgnore.isIgnoredEx(uriToGlobPath(uri));
241+
const results = await this.gitIgnore.isIgnoredEx(uriToGlobPath(uri));
242+
if (!results) return undefined;
243+
const info = { ...results };
244+
info.gitIgnoreFile = toFileURL(results.gitIgnoreFile).href;
245+
return info;
242246
}
243247

244248
async calcExcludedBy(uri: string): Promise<ExcludedByMatch[]> {

packages/_serverPatternMatcher/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
"yargs": "^17.7.2"
4747
},
4848
"dependencies": {
49-
"@cspell/cspell-types": "^8.17.5",
49+
"@cspell/cspell-types": "^8.18.0",
5050
"@internal/common-utils": "file:../__utils",
51-
"cspell-lib": "^8.17.5",
51+
"cspell-lib": "^8.18.0",
5252
"regexp-worker": "^3.0.0",
5353
"vscode-languageserver": "^9.0.1",
5454
"vscode-languageserver-textdocument": "^1.0.12",

packages/client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"webpack-cli": "^6.0.1"
5454
},
5555
"dependencies": {
56-
"@cspell/cspell-pipe": "^8.17.5",
57-
"@cspell/cspell-types": "^8.17.5",
56+
"@cspell/cspell-pipe": "^8.18.0",
57+
"@cspell/cspell-types": "^8.18.0",
5858
"@internal/common-utils": "file:../__utils",
5959
"@internal/locale-resolver": "file:../__locale-resolver",
6060
"@internal/server-pattern-matcher": "file:../_serverPatternMatcher",
@@ -64,7 +64,7 @@
6464
"camelize": "^1.0.1",
6565
"code-spell-checker-server": "file:../_server",
6666
"comment-json": "^4.2.5",
67-
"cspell-lib": "^8.17.5",
67+
"cspell-lib": "^8.18.0",
6868
"fast-deep-equal": "^3.1.3",
6969
"kefir": "^3.8.8",
7070
"optionator": "^0.9.4",

packages/client/src/infoViewer/infoHelper.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ function extractFileConfig(
199199
function extractGitignoreInfo(): FileConfig['gitignoreInfo'] {
200200
if (!gitignoreInfo) return undefined;
201201
const { glob, gitIgnoreFile, line, matched, root } = gitignoreInfo;
202-
const uri = Uri.file(gitIgnoreFile);
202+
const uri = Uri.parse(gitIgnoreFile);
203203
return {
204204
matched,
205205
glob,
206206
line,
207207
root,
208-
gitignoreFileUri: uri.toString(),
208+
gitignoreFileUri: gitIgnoreFile,
209209
gitignoreName: uriToName(uri),
210210
};
211211
}

packages/client/src/webview/api/api.mts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createDisposableList, type DisposableLike, disposeOf, injectDisposable, makeDisposable } from 'utils-disposables';
22
import { createLogger, LogLevel } from 'utils-logger';
3-
import { Uri, window } from 'vscode';
3+
import { Position, Range, Selection, Uri, window } from 'vscode';
44
import type { MessageConnection } from 'vscode-jsonrpc/node' with { 'resolution-mode': 'require' };
55
import type { RequestResult, SetValueRequest, SetValueResult, WatchFieldList, WatchFields } from 'webview-api';
66
import { createServerSideSpellInfoWebviewApi } from 'webview-api';
@@ -51,11 +51,21 @@ export function bindApiAndStore(connection: MessageConnection, store: Storage):
5151
async showInformationMessage(message) {
5252
await window.showInformationMessage('Show Message: ' + message);
5353
},
54-
async openTextDocument(url) {
54+
async openTextDocument(url, options) {
5555
if (!url) return;
5656
const uri = Uri.parse(url);
5757
// console.error('Open %o, %o', url, uri.toJSON());
58-
await window.showTextDocument(uri);
58+
const textEditor = await window.showTextDocument(uri);
59+
60+
if (options) {
61+
const { line, column = 1 } = options;
62+
if (line) {
63+
const pos = new Position(line - 1, column - 1);
64+
const range = new Range(pos, pos);
65+
textEditor.revealRange(range);
66+
textEditor.selection = new Selection(range.start, range.end);
67+
}
68+
}
5969
},
6070
},
6171
clientRequests: {},

packages/webview-api/src/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ export interface ServerRequestsAPI {
3636
watchFields(req: WatchFieldList): void;
3737
}
3838

39+
export interface OpenTextDocumentOptions {
40+
line?: number;
41+
column?: number;
42+
}
43+
3944
/** Notifications that can be sent to the extension */
4045
export interface ServerNotificationsAPI {
4146
showInformationMessage(message: string): void;
42-
openTextDocument(url: string): void;
47+
openTextDocument(url: string, options?: OpenTextDocumentOptions): void;
4348
}
4449

4550
/**

packages/webview-ui/src/views/CSpellInfo.svelte

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@
1818
interface DisplayInfo {
1919
key: string;
2020
value: string | undefined;
21-
url?: string;
21+
url?: string | undefined;
22+
line?: number | undefined;
2223
}
2324
2425
const maxDelay = 10000;
2526
const initialDelay = 1000;
2627
let fileInfo: DisplayInfo[] = $state([]);
2728
let delay = $state(initialDelay);
2829
29-
function openTextDocument(uri: string) {
30-
getServerNotificationApi().openTextDocument(uri);
30+
function openTextDocument(uri: string, line?: number | undefined) {
31+
getServerNotificationApi().openTextDocument(uri, line ? { line } : undefined);
3132
}
3233
3334
async function updateEnabledFileType(fileType: string | undefined, enable: boolean, url: URL | undefined) {
@@ -68,7 +69,8 @@
6869
(blocked && { key: 'Blocked Code', value: blocked.code }) || undefined,
6970
(blocked && { key: 'Blocked Help', value: 'See Documentation', url: blocked.documentationRefUri }) || undefined,
7071
(blocked && { key: 'Blocked Settings', value: 'VS Code Settings', url: blocked.settingsUri }) || undefined,
71-
(gitIgnore && { key: 'Blocked GitIgnore', value: gitIgnore.glob, url: gitIgnore.gitignoreFileUri }) || undefined,
72+
(gitIgnore && { key: 'Blocked GitIgnore', value: gitIgnore.glob, url: gitIgnore.gitignoreFileUri, line: gitIgnore.line }) ||
73+
undefined,
7274
);
7375
7476
return info.filter((a): a is DisplayInfo => !!a?.value);
@@ -115,7 +117,7 @@
115117
<dt>{entry.key}:</dt>
116118
<dd>
117119
{#if entry.url}
118-
<VscodeLink href={entry.url}>{entry.value}</VscodeLink>
120+
<VscodeLink href={entry.url} click={() => openTextDocument(entry.url || '', entry.line)}>{entry.value}</VscodeLink>
119121
{:else}
120122
{entry.value}
121123
{/if}
@@ -197,7 +199,7 @@
197199
{/if}
198200

199201
{#if unusedDictionaries && unusedDictionaries.length}
200-
<h2>Other Dictionaries</h2>
202+
<h2>Available Dictionaries</h2>
201203
<ul>
202204
{#each unusedDictionaries as dictionary}
203205
<li>

samples/custom-dictionary/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore the glob patterns below
2+
3+
*ignore.*

0 commit comments

Comments
 (0)