diff --git a/package-lock.json b/package-lock.json index 078fcc1819..ab1ea6fe0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "language-tools", - "version": "31.0.6981", + "version": "31.0.6986", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "language-tools", - "version": "31.0.6981", + "version": "31.0.6986", "license": "Apache-2.0", "devDependencies": { "@actions/core": "1.10.1", diff --git a/package.json b/package.json index 96ace597a7..9b599ba472 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "language-tools", "private": true, - "version": "31.0.6981", + "version": "31.0.6986", "author": "Prisma", "license": "Apache-2.0", "engines": { diff --git a/packages/language-server/package-lock.json b/packages/language-server/package-lock.json index 846547f17f..98fcfe62ee 100644 --- a/packages/language-server/package-lock.json +++ b/packages/language-server/package-lock.json @@ -1,16 +1,16 @@ { "name": "@prisma/language-server", - "version": "31.0.6981", + "version": "31.0.6986", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@prisma/language-server", - "version": "31.0.6981", + "version": "31.0.6986", "license": "Apache-2.0", "dependencies": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "@prisma/schema-files-loader": "5.17.0-dev.36", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "@prisma/schema-files-loader": "5.18.0-dev.1", "@types/js-levenshtein": "1.1.3", "js-levenshtein": "1.1.6", "klona": "2.0.6", @@ -533,16 +533,16 @@ } }, "node_modules/@prisma/prisma-schema-wasm": { - "version": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25.tgz", - "integrity": "sha512-bOqSBCigirXew8i50xTScgGi3RTnlBeClf4jsVr0YBtUT1bBU6hPxs0QfKMY9Oj4BN5PdO7Pp21M0Vleln5rTQ==" + "version": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a.tgz", + "integrity": "sha512-qxAcDS5Ju8xP5caGj0dNtzm/qYxnEz5gRnBg6jqhSQv5g3srplHNeGGosmE/nSSa7fomMjaPkjR+yjvcVoHr6w==" }, "node_modules/@prisma/schema-files-loader": { - "version": "5.17.0-dev.36", - "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.17.0-dev.36.tgz", - "integrity": "sha512-avuFgyERVerzV3BrnVuyFS0RRxYgn4VfwexJLc4XOwxqd+4SB3VmD0rwAKjKfmQiaigC6sVmiWU1f+9A9nn0iw==", + "version": "5.18.0-dev.1", + "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.18.0-dev.1.tgz", + "integrity": "sha512-eevZUtnFwYV8eNEYovz2Sh3CpbZL+XzmHV+qzQQzMj0oazmzNGUs5hDWzrIX6TLXkFlMG2cZvI/Mr1BeQdNCqw==", "dependencies": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", "fs-extra": "11.1.1" } }, @@ -2355,16 +2355,16 @@ } }, "@prisma/prisma-schema-wasm": { - "version": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25.tgz", - "integrity": "sha512-bOqSBCigirXew8i50xTScgGi3RTnlBeClf4jsVr0YBtUT1bBU6hPxs0QfKMY9Oj4BN5PdO7Pp21M0Vleln5rTQ==" + "version": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a.tgz", + "integrity": "sha512-qxAcDS5Ju8xP5caGj0dNtzm/qYxnEz5gRnBg6jqhSQv5g3srplHNeGGosmE/nSSa7fomMjaPkjR+yjvcVoHr6w==" }, "@prisma/schema-files-loader": { - "version": "5.17.0-dev.36", - "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.17.0-dev.36.tgz", - "integrity": "sha512-avuFgyERVerzV3BrnVuyFS0RRxYgn4VfwexJLc4XOwxqd+4SB3VmD0rwAKjKfmQiaigC6sVmiWU1f+9A9nn0iw==", + "version": "5.18.0-dev.1", + "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.18.0-dev.1.tgz", + "integrity": "sha512-eevZUtnFwYV8eNEYovz2Sh3CpbZL+XzmHV+qzQQzMj0oazmzNGUs5hDWzrIX6TLXkFlMG2cZvI/Mr1BeQdNCqw==", "requires": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", "fs-extra": "11.1.1" } }, diff --git a/packages/language-server/package.json b/packages/language-server/package.json index 48c7dad960..668f56bb95 100644 --- a/packages/language-server/package.json +++ b/packages/language-server/package.json @@ -2,7 +2,7 @@ "name": "@prisma/language-server", "description": "Prisma Language Server", "displayName": "Prisma Language Server", - "version": "31.0.6981", + "version": "31.0.6986", "author": "Prisma", "license": "Apache-2.0", "publisher": "Prisma", @@ -10,8 +10,8 @@ "node": ">=14" }, "prisma": { - "enginesVersion": "9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "cliVersion": "5.17.0-dev.36" + "enginesVersion": "7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "cliVersion": "5.18.0-dev.1" }, "bin": { "prisma-language-server": "dist/bin.js" @@ -29,8 +29,8 @@ "main": "./dist/index.js", "typings": "dist/src/index", "dependencies": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "@prisma/schema-files-loader": "5.17.0-dev.36", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "@prisma/schema-files-loader": "5.18.0-dev.1", "@types/js-levenshtein": "1.1.3", "js-levenshtein": "1.1.6", "klona": "2.0.6", diff --git a/packages/language-server/src/__test__/rename/multi-file.test.ts b/packages/language-server/src/__test__/rename/multi-file.test.ts index 76ff24e861..6a432aab41 100644 --- a/packages/language-server/src/__test__/rename/multi-file.test.ts +++ b/packages/language-server/src/__test__/rename/multi-file.test.ts @@ -93,7 +93,7 @@ test('rename model', async () => { `) }) -test('rename field', async () => { +test('rename field - map exists', async () => { const helper = await getMultifileHelper('user-posts') const user = helper.file('User.prisma') @@ -168,3 +168,68 @@ test('rename field', async () => { } `) }) + +test('rename field - map does not exist', async () => { + const helper = await getMultifileHelper('user-posts') + const user = helper.file('User.prisma') + + const response = handleRenameRequest(helper.schema, user.textDocument, { + textDocument: { + uri: user.uri, + }, + position: user.lineContaining('name String').characterAfter('na'), + newName: 'fullName', + }) + + expect(response).toMatchInlineSnapshot(` + { + "changes": { + "file:///user-posts/User.prisma": [ + { + "newText": "fullName", + "range": { + "end": { + "character": 8, + "line": 3, + }, + "start": { + "character": 4, + "line": 3, + }, + }, + }, + { + "newText": " @map("name")", + "range": { + "end": { + "character": 16, + "line": 3, + }, + "start": { + "character": 16, + "line": 3, + }, + }, + }, + ], + }, + } + `) + + expect(helper.applyChanges(response?.changes)).toMatchInlineSnapshot(` + { + "file:///user-posts/User.prisma": "/// This is the user of the platform + model User { + id String @id @default(uuid()) @map("_id") + fullName String @map("name") + email String + posts Post[] + + address Address + + favouriteAnimal FavouriteAnimal + } + ", + } + `) +}) diff --git a/packages/language-server/src/__test__/rename/single-file.test.ts b/packages/language-server/src/__test__/rename/single-file.test.ts index da3143d5cb..ecb3db1183 100644 --- a/packages/language-server/src/__test__/rename/single-file.test.ts +++ b/packages/language-server/src/__test__/rename/single-file.test.ts @@ -369,8 +369,8 @@ describe('Rename', () => { { newText: ' @map("Album")', range: { - start: { line: 136, character: 33 }, - end: { line: 136, character: 33 }, + start: { line: 136, character: 34 }, + end: { line: 136, character: 34 }, }, }, ], @@ -416,8 +416,8 @@ describe('Rename', () => { { newText: ' @map("authorId")', range: { - start: { line: 4, character: 16 }, - end: { line: 4, character: 16 }, + start: { line: 4, character: 17 }, + end: { line: 4, character: 17 }, }, }, { @@ -458,8 +458,8 @@ describe('Rename', () => { { newText: ' @map("title")', range: { - start: { line: 17, character: 16 }, - end: { line: 17, character: 16 }, + start: { line: 17, character: 17 }, + end: { line: 17, character: 17 }, }, }, { @@ -492,8 +492,8 @@ describe('Rename', () => { { newText: ' @map("humanId")', range: { - start: { line: 25, character: 13 }, - end: { line: 25, character: 13 }, + start: { line: 25, character: 14 }, + end: { line: 25, character: 14 }, }, }, { @@ -567,8 +567,8 @@ describe('Rename', () => { { newText: ' @map("A_VARIANT_WITH_UNDERSCORES")', range: { - start: { line: 8, character: 27 }, - end: { line: 8, character: 27 }, + start: { line: 8, character: 28 }, + end: { line: 8, character: 28 }, }, }, { diff --git a/packages/language-server/src/lib/code-actions/rename.ts b/packages/language-server/src/lib/code-actions/rename.ts index c823b7298b..a473fbe478 100644 --- a/packages/language-server/src/lib/code-actions/rename.ts +++ b/packages/language-server/src/lib/code-actions/rename.ts @@ -155,7 +155,7 @@ export function printLogMessage( } function insertInlineRename(currentName: string, line: Line): EditsMap { - const character = lastNoNewlineCharacter(line.untrimmedText) + const character = lastNewLineCharacter(line.untrimmedText) return { [line.document.uri]: [ { @@ -175,13 +175,15 @@ function insertInlineRename(currentName: string, line: Line): EditsMap { } } -function lastNoNewlineCharacter(lineText: string) { - for (let i = lineText.length - 1; i >= 0; i--) { - if (lineText[i] !== '\n' && lineText[i] !== '\r') { - return i - } +function lastNewLineCharacter(lineText: string) { + const i = lineText.length - 1 + if (lineText[i] === '\n' && lineText[i - 1] === '\r') { + return i - 1 + } else if (lineText[i] === '\n') { + return i + } else { + return 0 } - return 0 } function insertMapBlockAttribute(oldName: string, block: Block): EditsMap { diff --git a/packages/vscode/package-lock.json b/packages/vscode/package-lock.json index 09f029a247..100eccf554 100644 --- a/packages/vscode/package-lock.json +++ b/packages/vscode/package-lock.json @@ -1,15 +1,15 @@ { "name": "prisma-insider", - "version": "31.0.6981", + "version": "31.0.6986", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prisma-insider", - "version": "31.0.6981", + "version": "31.0.6986", "license": "Apache-2.0", "dependencies": { - "@prisma/language-server": "31.0.6981", + "@prisma/language-server": "31.0.6986", "checkpoint-client": "1.1.33", "env-paths": "2.2.1", "minimatch": "6.2.0", @@ -240,12 +240,12 @@ } }, "node_modules/@prisma/language-server": { - "version": "31.0.6981", - "resolved": "https://registry.npmjs.org/@prisma/language-server/-/language-server-31.0.6981.tgz", - "integrity": "sha512-btQKoxcvH2NkwoH7zJAomarKgYMKw6WOf7lp2ZagfAwhuxbT9W520GvZwiEMxLwHyH39LgSoCiwLV4WN7aur6Q==", + "version": "31.0.6986", + "resolved": "https://registry.npmjs.org/@prisma/language-server/-/language-server-31.0.6986.tgz", + "integrity": "sha512-/4/JUgOeFzMfsSQKDwF/xYJVbklE/QN81Th2Gc7p0dr5/V+CWRJoBuLo5br81Phl8BJh4vwStmo4pOmXhi+1YA==", "dependencies": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "@prisma/schema-files-loader": "5.17.0-dev.36", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "@prisma/schema-files-loader": "5.18.0-dev.1", "@types/js-levenshtein": "1.1.3", "js-levenshtein": "1.1.6", "klona": "2.0.6", @@ -261,16 +261,16 @@ } }, "node_modules/@prisma/prisma-schema-wasm": { - "version": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25.tgz", - "integrity": "sha512-bOqSBCigirXew8i50xTScgGi3RTnlBeClf4jsVr0YBtUT1bBU6hPxs0QfKMY9Oj4BN5PdO7Pp21M0Vleln5rTQ==" + "version": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a.tgz", + "integrity": "sha512-qxAcDS5Ju8xP5caGj0dNtzm/qYxnEz5gRnBg6jqhSQv5g3srplHNeGGosmE/nSSa7fomMjaPkjR+yjvcVoHr6w==" }, "node_modules/@prisma/schema-files-loader": { - "version": "5.17.0-dev.36", - "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.17.0-dev.36.tgz", - "integrity": "sha512-avuFgyERVerzV3BrnVuyFS0RRxYgn4VfwexJLc4XOwxqd+4SB3VmD0rwAKjKfmQiaigC6sVmiWU1f+9A9nn0iw==", + "version": "5.18.0-dev.1", + "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.18.0-dev.1.tgz", + "integrity": "sha512-eevZUtnFwYV8eNEYovz2Sh3CpbZL+XzmHV+qzQQzMj0oazmzNGUs5hDWzrIX6TLXkFlMG2cZvI/Mr1BeQdNCqw==", "dependencies": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", "fs-extra": "11.1.1" } }, @@ -4057,12 +4057,12 @@ } }, "@prisma/language-server": { - "version": "31.0.6981", - "resolved": "https://registry.npmjs.org/@prisma/language-server/-/language-server-31.0.6981.tgz", - "integrity": "sha512-btQKoxcvH2NkwoH7zJAomarKgYMKw6WOf7lp2ZagfAwhuxbT9W520GvZwiEMxLwHyH39LgSoCiwLV4WN7aur6Q==", + "version": "31.0.6986", + "resolved": "https://registry.npmjs.org/@prisma/language-server/-/language-server-31.0.6986.tgz", + "integrity": "sha512-/4/JUgOeFzMfsSQKDwF/xYJVbklE/QN81Th2Gc7p0dr5/V+CWRJoBuLo5br81Phl8BJh4vwStmo4pOmXhi+1YA==", "requires": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "@prisma/schema-files-loader": "5.17.0-dev.36", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "@prisma/schema-files-loader": "5.18.0-dev.1", "@types/js-levenshtein": "1.1.3", "js-levenshtein": "1.1.6", "klona": "2.0.6", @@ -4072,16 +4072,16 @@ } }, "@prisma/prisma-schema-wasm": { - "version": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", - "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25.tgz", - "integrity": "sha512-bOqSBCigirXew8i50xTScgGi3RTnlBeClf4jsVr0YBtUT1bBU6hPxs0QfKMY9Oj4BN5PdO7Pp21M0Vleln5rTQ==" + "version": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", + "resolved": "https://registry.npmjs.org/@prisma/prisma-schema-wasm/-/prisma-schema-wasm-5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a.tgz", + "integrity": "sha512-qxAcDS5Ju8xP5caGj0dNtzm/qYxnEz5gRnBg6jqhSQv5g3srplHNeGGosmE/nSSa7fomMjaPkjR+yjvcVoHr6w==" }, "@prisma/schema-files-loader": { - "version": "5.17.0-dev.36", - "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.17.0-dev.36.tgz", - "integrity": "sha512-avuFgyERVerzV3BrnVuyFS0RRxYgn4VfwexJLc4XOwxqd+4SB3VmD0rwAKjKfmQiaigC6sVmiWU1f+9A9nn0iw==", + "version": "5.18.0-dev.1", + "resolved": "https://registry.npmjs.org/@prisma/schema-files-loader/-/schema-files-loader-5.18.0-dev.1.tgz", + "integrity": "sha512-eevZUtnFwYV8eNEYovz2Sh3CpbZL+XzmHV+qzQQzMj0oazmzNGUs5hDWzrIX6TLXkFlMG2cZvI/Mr1BeQdNCqw==", "requires": { - "@prisma/prisma-schema-wasm": "5.17.0-30.9721e9ba461e8bae3b4bb2acac96d8d80ef01c25", + "@prisma/prisma-schema-wasm": "5.18.0-1.7484fd8557ad7be2d029bb2d4d43b6ef68a0200a", "fs-extra": "11.1.1" } }, diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 87662321e0..0f425c4df8 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -2,7 +2,7 @@ "name": "prisma-insider", "displayName": "Prisma - Insider", "description": "This is the Insider Build of the Prisma VS Code extension (only use it if you are also using the dev version of the CLI).", - "version": "31.0.6981", + "version": "31.0.6986", "license": "Apache-2.0", "icon": "logo_white.png", "engines": { @@ -13,7 +13,7 @@ "Programming Languages" ], "dependencies": { - "@prisma/language-server": "31.0.6981", + "@prisma/language-server": "31.0.6986", "checkpoint-client": "1.1.33", "env-paths": "2.2.1", "minimatch": "6.2.0", diff --git a/scripts/versions/extension_insider b/scripts/versions/extension_insider index 7e4a5dd6f5..7a67c58c6d 100644 --- a/scripts/versions/extension_insider +++ b/scripts/versions/extension_insider @@ -1 +1 @@ -31.0.6981 \ No newline at end of file +31.0.6986 \ No newline at end of file diff --git a/scripts/versions/extension_stable b/scripts/versions/extension_stable index 89f2faf24b..54ba60d491 100644 --- a/scripts/versions/extension_stable +++ b/scripts/versions/extension_stable @@ -1 +1 @@ -5.16.2 \ No newline at end of file +5.17.0 \ No newline at end of file diff --git a/scripts/versions/prisma_dev b/scripts/versions/prisma_dev index f1253d3ee4..681c767023 100644 --- a/scripts/versions/prisma_dev +++ b/scripts/versions/prisma_dev @@ -1 +1 @@ -5.17.0-dev.36 +5.18.0-dev.1 diff --git a/scripts/versions/prisma_latest b/scripts/versions/prisma_latest index 9aa54ea304..ad95545a81 100644 --- a/scripts/versions/prisma_latest +++ b/scripts/versions/prisma_latest @@ -1 +1 @@ -5.16.2 +5.17.0 diff --git a/scripts/versions/tested_extension_insider b/scripts/versions/tested_extension_insider index adf7bf7f8e..42d779ec33 100644 --- a/scripts/versions/tested_extension_insider +++ b/scripts/versions/tested_extension_insider @@ -1 +1 @@ -31.0.6981 +31.0.6986 diff --git a/scripts/versions/tested_extension_stable b/scripts/versions/tested_extension_stable index 04218f11c3..ad95545a81 100644 --- a/scripts/versions/tested_extension_stable +++ b/scripts/versions/tested_extension_stable @@ -1 +1 @@ -5.16.1 +5.17.0