"Apply Method" failing ("Apply Method Consistently Fails to Preserve Code Context and Structure")

I am building a Swift app using Cursor. Things are mostly going well, but all of a sudden I am now having issues where I ask it to make a very basic change (something as simple as changing an abbreviation in the app’s UI) and it will go through 8-9-10 iterations before it finally solves the issue and gets the revision to work. This is often accompanied by a number of linter errors that Cursor keeps trying to fix, along with repeated comments that the “apply method” was not behaving as Cursor expected it to. Since, heck, it’s AI, and Cursor can itself see it’s having issues, I asked it to summarize for a bug report what the nature of the problem was it was having. Here’s what it said:

Description

The Apply method in Cursor is exhibiting consistent issues with code modification, particularly around context preservation and structural integrity. These issues occur across multiple attempts and chat sessions, suggesting systematic problems rather than isolated incidents.

Specific Issues Observed

1. Complete File Replacement

When attempting to update method signatures or make targeted changes, the Apply method sometimes replaces entire file contents instead of making focused modifications. This occurs despite:

  • Providing specific context

  • Using // ... existing code ... markers

  • Making small, focused changes

2. Method Signature Inconsistency

The Apply method shows problematic behavior with method signatures:

  • Changes method signatures without updating corresponding calls

  • Generates new method signatures instead of modifying existing ones

  • Loses track of relationships between method declarations and usages

3. Context Preservation Failure

The method fails to maintain important code context:

  • Loses track of class boundaries and scope

  • Doesn’t maintain relationships between related methods

  • Ignores hierarchical structure of the code

4. Partial Edit Problems

When using // ... existing code ... markers:

  • Interprets markers as instructions to replace everything between them

  • Doesn’t properly preserve existing code structure

  • Removes unrelated code that should be preserved

5. Build Breaking Changes

Consistently introduces changes that break builds:

  • Modifies method signatures causing linter errors

  • Creates inconsistencies between declarations and calls

  • Requires manual intervention (git checkout) to restore working code

Steps to Reproduce

  1. Attempt to modify a method signature in a Swift file

  2. Use // ... existing code ... markers to preserve existing code

  3. Make the change and observe the Apply method’s behavior

Expected Behavior

  • Apply method should make targeted changes while preserving:

  • File structure

  • Method relationships

  • Code context

  • Build integrity

Actual Behavior

  • Apply method replaces entire file contents

  • Breaks method signatures and calls

  • Requires manual restoration of working code

Environment

  • OS: macOS 24.3.0

  • Cursor Version: [Current Version]

  • File Type: Swift

  • Project Type: iOS/macOS Application

Additional Context

These issues occur consistently across multiple attempts and chat sessions, suggesting they are systematic rather than isolated incidents. The problems persist even when:

  • Making small, focused changes

  • Providing explicit context

  • Using clear markers for code preservation

  • Starting fresh chat sessions

Impact

These issues significantly impact development workflow by:

  • Requiring manual code restoration

  • Breaking builds

  • Creating inconsistent code states

  • Increasing development time

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.