Skip to content

Commit

Permalink
fix rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Druue committed Jul 16, 2024
1 parent ae386f4 commit 0fc25fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ test('rename field - map does not exist', async () => {
"newText": " @map("name")",
"range": {
"end": {
"character": 15,
"character": 16,
"line": 3,
},
"start": {
"character": 15,
"character": 16,
"line": 3,
},
},
Expand All @@ -221,7 +221,7 @@ test('rename field - map does not exist', async () => {
"file:///user-posts/User.prisma": "/// This is the user of the platform
model User {
id String @id @default(uuid()) @map("_id")
fullName Strin @map("name")g
fullName String @map("name")
email String
posts Post[]
Expand Down
11 changes: 1 addition & 10 deletions packages/language-server/src/lib/code-actions/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function printLogMessage(
}

function insertInlineRename(currentName: string, line: Line): EditsMap {
const character = lastNoNewlineCharacter(line.untrimmedText)
const character = line.untrimmedText.length - 1
return {
[line.document.uri]: [
{
Expand All @@ -175,15 +175,6 @@ 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
}
}
return 0
}

function insertMapBlockAttribute(oldName: string, block: Block): EditsMap {
return {
[block.definingDocument.uri]: [
Expand Down

0 comments on commit 0fc25fb

Please sign in to comment.