@@ -188,51 +188,66 @@ function M.create(status_result, git_root, tabpage, width, base_revision, target
188188 -- Handle untracked files: show file without diff
189189 if file_data .status == " ??" then
190190 vim .schedule (function ()
191- local side_by_side = require (" codediff.ui.view.side_by_side" )
192- side_by_side .show_untracked_file (tabpage , abs_path )
191+ local sess = lifecycle .get_session (tabpage )
192+ if sess and sess .layout == " inline" then
193+ require (" codediff.ui.view.inline_view" ).show_single_file (tabpage , abs_path )
194+ else
195+ require (" codediff.ui.view.side_by_side" ).show_untracked_file (tabpage , abs_path )
196+ end
193197 end )
194198 return
195199 end
196200
197201 -- Handle added files: only one side has the file
198202 if file_data .status == " A" then
199- if base_revision and target_revision and target_revision ~= " WORKING" then
200- -- Two-revision mode: show target revision content only
201- vim .schedule (function ()
202- local side_by_side = require (" codediff.ui.view.side_by_side" )
203- side_by_side .show_added_virtual_file (tabpage , git_root , file_path , target_revision )
204- end )
205- elseif group == " staged" then
206- -- Staged mode: file exists in staging (:0) but not in HEAD
207- vim .schedule (function ()
208- local side_by_side = require (" codediff.ui.view.side_by_side" )
209- side_by_side .show_added_virtual_file (tabpage , git_root , file_path , " :0" )
210- end )
211- else
212- -- Unstaged/working tree: file exists on disk but not in any revision
213- vim .schedule (function ()
214- local side_by_side = require (" codediff.ui.view.side_by_side" )
215- side_by_side .show_untracked_file (tabpage , abs_path )
216- end )
217- end
203+ vim .schedule (function ()
204+ local sess = lifecycle .get_session (tabpage )
205+ local is_inline = sess and sess .layout == " inline"
206+
207+ if base_revision and target_revision and target_revision ~= " WORKING" then
208+ if is_inline then
209+ require (" codediff.ui.view.inline_view" ).show_single_file (tabpage , file_path , { revision = target_revision , git_root = git_root , rel_path = file_path })
210+ else
211+ require (" codediff.ui.view.side_by_side" ).show_added_virtual_file (tabpage , git_root , file_path , target_revision )
212+ end
213+ elseif group == " staged" then
214+ if is_inline then
215+ require (" codediff.ui.view.inline_view" ).show_single_file (tabpage , file_path , { revision = " :0" , git_root = git_root , rel_path = file_path })
216+ else
217+ require (" codediff.ui.view.side_by_side" ).show_added_virtual_file (tabpage , git_root , file_path , " :0" )
218+ end
219+ else
220+ if is_inline then
221+ require (" codediff.ui.view.inline_view" ).show_single_file (tabpage , abs_path )
222+ else
223+ require (" codediff.ui.view.side_by_side" ).show_untracked_file (tabpage , abs_path )
224+ end
225+ end
226+ end )
218227 return
219228 end
220229
221230 -- Handle deleted files: show old content without diff
222231 if file_data .status == " D" then
223- if base_revision and target_revision and target_revision ~= " WORKING" then
224- -- Two-revision mode: use base_revision
225- vim .schedule (function ()
226- local side_by_side = require (" codediff.ui.view.side_by_side" )
227- side_by_side .show_deleted_virtual_file (tabpage , git_root , file_path , base_revision )
228- end )
229- else
230- -- Working tree mode: use staged or HEAD
231- vim .schedule (function ()
232- local side_by_side = require (" codediff.ui.view.side_by_side" )
233- side_by_side .show_deleted_file (tabpage , git_root , file_path , abs_path , group )
234- end )
235- end
232+ vim .schedule (function ()
233+ local sess = lifecycle .get_session (tabpage )
234+ local is_inline = sess and sess .layout == " inline"
235+
236+ if base_revision and target_revision and target_revision ~= " WORKING" then
237+ if is_inline then
238+ require (" codediff.ui.view.inline_view" ).show_single_file (tabpage , file_path , { revision = base_revision , git_root = git_root , rel_path = file_path })
239+ else
240+ require (" codediff.ui.view.side_by_side" ).show_deleted_virtual_file (tabpage , git_root , file_path , base_revision )
241+ end
242+ else
243+ if is_inline then
244+ local revision = (group == " staged" ) and " HEAD" or " :0"
245+ require (" codediff.ui.view.inline_view" ).show_single_file (tabpage , file_path , { revision = revision , git_root = git_root , rel_path = file_path })
246+ else
247+ require (" codediff.ui.view.side_by_side" ).show_deleted_file (tabpage , git_root , file_path , abs_path , group )
248+ end
249+ end
250+ end )
236251 return
237252 end
238253
0 commit comments